Commit cb0c7113 authored by Melroy van den Berg's avatar Melroy van den Berg

Open file picker automatically, close pop-ups automatically

parent 7c1bd156
......@@ -2,6 +2,7 @@
Marktplaats specific methods, an extenstion of the MozRepl class
"""
from mozrepl import MozRepl
from time import sleep
class Marktplaats(MozRepl):
def __init__(self):
......@@ -47,10 +48,20 @@ class Marktplaats(MozRepl):
# From this moment on, the write_data/read_data calls COULD be important to
# run in context of content (enter(content)), use read_data(true) when applicable and check the valid flag
# Wait a bit longer to load the page fully
sleep(0.5)
# Change delivery method
self.change_delivery_method_to_send_or_pickup()
self.change_delivery_method_to_parcel_30kg()
# Trigger file picker
self.open_image_picker()
while True:
self.close_pop_up_frontpage()
sleep(2)
# When no blocking url is defined use input URL instead
if blocking_url == "":
blocking_url = url
......@@ -58,6 +69,21 @@ class Marktplaats(MozRepl):
# Blocking wait until the current URL is different from the 'blocking url' (form submitted)
self.wait_until_url_changed(blocking_url, exception_url)
def open_image_picker(self):
"""
Trigger Open file picker (multiple files) in Marktplaats
"""
self.write_data(b"document.getElementById('file-picker-0').click()")
self.skip_data()
def close_pop_up_frontpage(self):
self.write_data(b"document.getElementById('blikvanger-dialog').style.display")
display = self.read_data()
if display != b'"none"':
self.write_data(b"document.getElementById('blikvanger-dialog').style.display = 'none'; document.getElementById('overlay').style.display = 'none';")
self.skip_data()
def change_delivery_method_to_send_or_pickup(self):
"""
Change the select dropbox item in Marktplaats ("Ophalen of Verzenden"), to index 3 == Ophalen of Verzenden
......@@ -135,3 +161,4 @@ class Marktplaats(MozRepl):
self.set_hidden_input_field_form("syi-form", "shippingDetails.productCode", "1000")
self.set_hidden_input_field_form("syi-form", "shippingDetails.catalogName", "letters")
self.set_hidden_input_field_form("syi-form", "shippingDetails.averageWeight", "175")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment