@@ -36,26 +36,26 @@ class SeleniumRunner:
3636 """
3737 ICOMOON_URL = "https://icomoon.io/app/#/select"
3838
39- def __init__ (self , icomoon_json_path : str , download_path : str ,
40- geckodriver_path : str , headless ):
39+ def __init__ (self , download_path : str ,
40+ geckodriver_path : str , headless : bool ):
4141 """
4242 Create a SeleniumRunner object.
43- :param icomoon_json_path: a path to the iconmoon.json.
4443 :param download_path: the location where you want to download
4544 the icomoon.zip to.
4645 :param geckodriver_path: the path to the firefox executable.
4746 :param headless: whether to run browser in headless (no UI) mode.
4847 """
49- self .icomoon_json_path = icomoon_json_path
50- self .download_path = download_path
5148 self .driver = None
52- self .set_options (geckodriver_path , headless )
49+ self .set_options (download_path , geckodriver_path , headless )
5350
54- def set_options (self , geckodriver_path : str , headless : bool ):
51+ def set_options (self , download_path : str , geckodriver_path : str ,
52+ headless : bool ):
5553 """
5654 Build the WebDriver with Firefox Options allowing downloads and
5755 set download to download_path.
56+ :param download_path: the location where you want to download
5857 :param geckodriver_path: the path to the firefox executable.
58+ the icomoon.zip to.
5959 :param headless: whether to run browser in headless (no UI) mode.
6060
6161 :raises AssertionError: if the page title does not contain
@@ -69,25 +69,34 @@ def set_options(self, geckodriver_path: str, headless: bool):
6969
7070 # set the default download path to downloadPath
7171 options .set_preference ("browser.download.folderList" , 2 )
72- options .set_preference ("browser.download.dir" , self . download_path )
72+ options .set_preference ("browser.download.dir" , download_path )
7373 options .headless = headless
7474
7575 self .driver = WebDriver (options = options , executable_path = geckodriver_path )
7676 self .driver .get (self .ICOMOON_URL )
7777 assert "IcoMoon App" in self .driver .title
78-
79- def upload_icomoon (self ):
78+
79+ # wait until the whole web page is loaded by testing the hamburger input
80+ hamburger_input = WebDriverWait (self .driver , SeleniumRunner .LONG_WAIT_IN_SEC ).until (
81+ ec .element_to_be_clickable ((By .CSS_SELECTOR ,
82+ "button.btn5.lh-def.transparent i.icon-menu" ))
83+ )
84+ hamburger_input .click ()
85+ print ("Accessed icomoon.io" )
86+
87+ def upload_icomoon (self , icomoon_json_path : str ):
8088 """
8189 Upload the icomoon.json to icomoon.io.
90+ :param icomoon_json_path: a path to the iconmoon.json.
8291 :raises TimeoutException: happens when elements are not found.
8392 """
8493 print ("Uploading icomoon.json file..." )
8594 try :
8695 # find the file input and enter the file path
8796 import_btn = WebDriverWait (self .driver , SeleniumRunner .LONG_WAIT_IN_SEC ).until (
88- ec .presence_of_element_located ((By .CSS_SELECTOR , "div#file input" ))
97+ ec .element_to_be_clickable ((By .CSS_SELECTOR , "div#file input" ))
8998 )
90- import_btn .send_keys (self . icomoon_json_path )
99+ import_btn .send_keys (icomoon_json_path )
91100 except Exception as e :
92101 self .close ()
93102 raise e
@@ -130,11 +139,14 @@ def upload_svgs(self, svgs: List[str]):
130139 self .test_for_possible_alert (self .SHORT_WAIT_IN_SEC , "Dismiss" )
131140 self .remove_color_from_icon ()
132141
142+ # take a screenshot of the icons that were just added
143+ self .driver .save_screenshot ("new_icons.png" );
133144 self .click_hamburger_input ()
134145 select_all_button = WebDriverWait (self .driver , self .LONG_WAIT_IN_SEC ).until (
135146 ec .element_to_be_clickable ((By .XPATH , "//button[text()='Select All']" ))
136147 )
137148 select_all_button .click ()
149+ print ("Finished uploading the svgs..." )
138150 except Exception as e :
139151 self .close ()
140152 raise e
@@ -152,7 +164,7 @@ def click_hamburger_input(self):
152164 )
153165
154166 menu_appear_callback = ec .element_to_be_clickable (
155- (By .CSS_SELECTOR , "h1#setH2 ul" )
167+ (By .CSS_SELECTOR , "h1 ul.menuList2 " )
156168 )
157169
158170 while not menu_appear_callback (self .driver ):
0 commit comments