Skip to content

Commit dc0accb

Browse files
committed
format
1 parent 3b7313c commit dc0accb

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

modules/page_base.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,19 @@ def get_all_children(
541541
children = element.find_elements(By.XPATH, "./*")
542542
return children
543543

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+
544557
def wait_for_num_tabs(self, num_tabs: int) -> Page:
545558
"""
546559
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:
551564
logging.warn("Timeout waiting for the number of windows to be:", num_tabs)
552565
return self
553566

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-
564567
def switch_to_new_tab(self) -> Page:
565568
"""Get list of all window handles, switch to the newly opened tab"""
566569
handles = self.driver.window_handles

0 commit comments

Comments
 (0)