def expand_tree(self, node_count):
"""expand_tree expands treeview (dynatree) by clicking expander arrows one by one"""
self.wait_for_frameworks()
WebDriverWait(self.selenium, 10).until(EC.element_to_be_clickable(self.expander_locator))
WebDriverWait(self.selenium, 10).until(lambda _: len(self.expanders) == node_count)
# least-work way to fight ElementNotVisibleException: Message: Cannot click on element, and
# http://stackoverflow.com/questions/37781539/selenium-stale-element-reference-element-is-not-attached-to-the-page-document/38683022
def loop():
self.wait_for_frameworks()
for expander in self.expanders: # type: WebElement
node = self.retry_on_exception(NoSuchElementException, lambda: expander.find_element(By.XPATH, './..'))
if self.is_expanded(node):
continue
self.wait_for_frameworks()
expander.click()
self.wait_for_frameworks()
self.retry_on_exception(StaleElementReferenceException, loop)
self.assert_tree_expanded()
评论列表
文章目录