@@ -541,6 +541,19 @@ def get_all_children(
541
541
children = element .find_elements (By .XPATH , "./*" )
542
542
return children
543
543
544
+ def wait_for_no_children (
545
+ self , parent : Union [str , tuple , WebElement ], labels = []
546
+ ) -> Page :
547
+ """
548
+ Waits for 0 children under the given parent, the wait is instant (note, this changes the driver implicit wait and changes it back)
549
+ """
550
+ driver_wait = self .driver .timeouts .implicit_wait
551
+ self .driver .implicitly_wait (0 )
552
+ try :
553
+ assert len (self .get_all_children (self .fetch (parent , labels ))) == 0
554
+ finally :
555
+ self .driver .implicitly_wait (driver_wait )
556
+
544
557
def wait_for_num_tabs (self , num_tabs : int ) -> Page :
545
558
"""
546
559
Waits for the driver.window_handles to be updated accordingly with the number of tabs requested
@@ -551,16 +564,6 @@ def wait_for_num_tabs(self, num_tabs: int) -> Page:
551
564
logging .warn ("Timeout waiting for the number of windows to be:" , num_tabs )
552
565
return self
553
566
554
- def wait_for_no_children (
555
- self , parent : Union [str , tuple , WebElement ], labels = []
556
- ) -> Page :
557
- """
558
- Waits for 0 children under the given parent, the wait is instant
559
- """
560
- self .instawait .until (
561
- lambda _ : len (self .get_all_children (self .fetch (parent , labels ))) == 0
562
- )
563
-
564
567
def switch_to_new_tab (self ) -> Page :
565
568
"""Get list of all window handles, switch to the newly opened tab"""
566
569
handles = self .driver .window_handles
0 commit comments