elementaction.py 文件源码

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

项目:python-behave-automation-framework 作者: pradeepta02 项目源码 文件源码
def select_by_visible_text(self, locator, option_text, replacement=None, retry_by_browser_refresh=False):
        """Select an option by visible option text
        :param locator: locator of select element
        :param replacement: if locator contains dynamic part, i.e. '$value',
        it will be replaced by replacement variable
        :param option_text: option text by which to select the option
        :param retry_by_browser_refresh: if set to True, when webdriver is not able to find any element,
        it will refresh the browser and try to find the element again
        :return: None
        """
        if replacement:
            locator = locator.replace('$value', replacement)

        try:
            select = Select(self.fetch_element(locator))
            select.select_by_visible_text(option_text)

            self.context.logger.info("Selected element '" + locator + "' by visible text '" + option_text + "'")
        except Exception as e:
            self.context.logger.error("Unable to select option '" + option_text + "'. Error: %s" % e,
                                      exc_info=True)
            Assert.assert_fail("Unable to select option '" + option_text + "'")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号