page_objects.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:dispatch-console-tests 作者: jdanekrh 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号