@@ -256,6 +256,77 @@ def open_tracker_panel(self) -> BasePage:
256
256
self .get_element ("shield-icon" ).click ()
257
257
return self
258
258
259
+ def wait_for_item_to_download (self , filename : str ) -> BasePage :
260
+ """
261
+ Check the downloads tool in the toolbar to wait for a given file to download
262
+ """
263
+ original_timeout = self .driver .timeouts .implicit_wait
264
+ try :
265
+ # Whatever our timeout, we want to lengthen it because downloads
266
+ self .driver .implicitly_wait (original_timeout * 2 )
267
+ self .element_visible ("downloads-item-by-file" , labels = [filename ])
268
+ self .expect_not (
269
+ EC .element_attribute_to_include (
270
+ self .get_selector ("downloads-button" ), "animate"
271
+ )
272
+ )
273
+ with self .driver .context (self .context_id ):
274
+ self .driver .execute_script (
275
+ "arguments[0].setAttribute('hidden', true)" ,
276
+ self .get_element ("downloads-button" ),
277
+ )
278
+ finally :
279
+ self .driver .implicitly_wait (original_timeout )
280
+ return self
281
+
282
+ @BasePage .context_chrome
283
+ def refresh_page (self ) -> BasePage :
284
+ """
285
+ Refreshes the current page by clicking the refresh button in the browser.
286
+ """
287
+
288
+ self .get_element ("refresh-button" ).click ()
289
+ self .wait_for_page_to_load ()
290
+ return self
291
+
292
+ def handle_geolocation_prompt (self , button_type = "primary" ):
293
+ """
294
+ Handles geolocation prompt by clicking either the 'Allow' or 'Block' button based on the button_type provided
295
+ """
296
+ button_selector = f"popup-notification-{ button_type } -button"
297
+ self .element_clickable (button_selector )
298
+ self .click_on (button_selector )
299
+
300
+ def open_searchmode_switcher_settings (self ):
301
+ """Open search settings from searchmode switcher in awesome bar"""
302
+ self .click_on ("searchmode-switcher" )
303
+ self .click_on ("searchmode-switcher-settings" )
304
+ return self
305
+
306
+ @BasePage .context_chrome
307
+ def select_element_in_nav (self , element : str ) -> BasePage :
308
+ self .get_element (element ).click ()
309
+ return self
310
+
311
+ # Bookmark
312
+
313
+ @BasePage .context_chrome
314
+ def add_bookmark_via_star_icon (self ) -> BasePage :
315
+ """
316
+ Bookmark a site via star button and click save on the bookmark panel
317
+ """
318
+ self .get_element ("star-button" ).click ()
319
+ self .get_element ("save-bookmark-button" ).click ()
320
+ return self
321
+
322
+ @BasePage .context_chrome
323
+ def verify_star_button_is_blue (self ) -> BasePage :
324
+ """
325
+ Verifies that the star button is blue (indicating a bookmarked page)
326
+ """
327
+ self .element_visible ("blue-star-button" )
328
+ return self
329
+
259
330
@BasePage .context_chrome
260
331
def bookmark_page_other (self ) -> BasePage :
261
332
self .get_element ("star-button" ).click ()
@@ -289,25 +360,6 @@ def add_bookmark_advanced(
289
360
ba .switch_to_content_context ()
290
361
return self
291
362
292
- @BasePage .context_chrome
293
- def add_bookmark_via_star (self ) -> BasePage :
294
- """
295
- Bookmark a site via star button and click save on the bookmark panel
296
- """
297
- self .get_element ("star-button" ).click ()
298
- self .get_element ("save-bookmark-button" ).click ()
299
- return self
300
-
301
- @BasePage .context_chrome
302
- def add_bookmark_via_menu (self ) -> BasePage :
303
- """
304
- Bookmark a site via bookmarks menu and click save on the bookmark panel
305
- """
306
-
307
- self .get_element ("bookmark-current-tab" ).click ()
308
- self .get_element ("save-bookmark-button" ).click ()
309
- return self
310
-
311
363
@BasePage .context_chrome
312
364
def toggle_bookmarks_toolbar_with_key_combo (self ) -> BasePage :
313
365
"""Use Cmd/Ctrl + B to open the Print Preview, wait for load"""
@@ -319,29 +371,6 @@ def toggle_bookmarks_toolbar_with_key_combo(self) -> BasePage:
319
371
self .perform_key_combo (mod_key , Keys .SHIFT , "b" )
320
372
return self
321
373
322
- def wait_for_item_to_download (self , filename : str ) -> BasePage :
323
- """
324
- Check the downloads tool in the toolbar to wait for a given file to download
325
- """
326
- original_timeout = self .driver .timeouts .implicit_wait
327
- try :
328
- # Whatever our timeout, we want to lengthen it because downloads
329
- self .driver .implicitly_wait (original_timeout * 2 )
330
- self .element_visible ("downloads-item-by-file" , labels = [filename ])
331
- self .expect_not (
332
- EC .element_attribute_to_include (
333
- self .get_selector ("downloads-button" ), "animate"
334
- )
335
- )
336
- with self .driver .context (self .context_id ):
337
- self .driver .execute_script (
338
- "arguments[0].setAttribute('hidden', true)" ,
339
- self .get_element ("downloads-button" ),
340
- )
341
- finally :
342
- self .driver .implicitly_wait (original_timeout )
343
- return self
344
-
345
374
@BasePage .context_chrome
346
375
def confirm_bookmark_exists (self , match_string : str ) -> BasePage :
347
376
"""
@@ -361,32 +390,3 @@ def confirm_bookmark_exists(self, match_string: str) -> BasePage:
361
390
)
362
391
assert matches_short_string or matches_long_string
363
392
return self
364
-
365
- @BasePage .context_chrome
366
- def refresh_page (self ) -> BasePage :
367
- """
368
- Refreshes the current page by clicking the refresh button in the browser.
369
- """
370
-
371
- self .get_element ("refresh-button" ).click ()
372
- self .wait_for_page_to_load ()
373
- return self
374
-
375
- def handle_geolocation_prompt (self , button_type = "primary" ):
376
- """
377
- Handles geolocation prompt by clicking either the 'Allow' or 'Block' button based on the button_type provided
378
- """
379
- button_selector = f"popup-notification-{ button_type } -button"
380
- self .element_clickable (button_selector )
381
- self .click_on (button_selector )
382
-
383
- def open_searchmode_switcher_settings (self ):
384
- """Open search settings from searchmode switcher in awesome bar"""
385
- self .click_on ("searchmode-switcher" )
386
- self .click_on ("searchmode-switcher-settings" )
387
- return self
388
-
389
- @BasePage .context_chrome
390
- def select_element_in_nav (self , element : str ) -> BasePage :
391
- self .get_element (element ).click ()
392
- return self
0 commit comments