当前位置: 首页>>代码示例>>Python>>正文


Python By.is_valid方法代码示例

本文整理汇总了Python中selenium.webdriver.common.by.By.is_valid方法的典型用法代码示例。如果您正苦于以下问题:Python By.is_valid方法的具体用法?Python By.is_valid怎么用?Python By.is_valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在selenium.webdriver.common.by.By的用法示例。


在下文中一共展示了By.is_valid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: find_elements

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import is_valid [as 别名]
    def find_elements(self, by=By.ID, value=None):
        """
        'Private' method used by the find_elements_by_* methods.

        :Usage:
            Use the corresponding find_elements_by_* instead of this.

        :rtype: list of WebElement
        """
        if not By.is_valid(by) or not isinstance(value, str):
            raise InvalidSelectorException("Invalid locator values passed in")
        if self.w3c:
            if by == By.ID:
                by = By.CSS_SELECTOR
                value = '[id="%s"]' % value
            elif by == By.TAG_NAME:
                by = By.CSS_SELECTOR
            elif by == By.CLASS_NAME:
                by = By.CSS_SELECTOR
                value = ".%s" % value
            elif by == By.NAME:
                by = By.CSS_SELECTOR
                value = '[name="%s"]' % value

        return self.execute(Command.FIND_ELEMENTS,
                             {'using': by, 'value': value})['value']
开发者ID:nvonop,项目名称:selenium,代码行数:28,代码来源:webdriver.py

示例2: method

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import is_valid [as 别名]
    def method(self, by=By.ID, value=None):
        if By.is_valid(by) and by == By.CLASS_NAME:
            by = By.CSS_SELECTOR
            value = "." + value

        if original.im_self:
            return original(by, value)
        else:
            return original(self, by, value)
开发者ID:AMHZR,项目名称:selenic,代码行数:11,代码来源:config.py

示例3: find_elements

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import is_valid [as 别名]
    def find_elements(self, by=By.ID, value=None):
        """
        'Private' method used by the find_elements_by_* methods.

        :Usage:
            Use the corresponding find_elements_by_* instead of this.
        """
        if not By.is_valid(by) or not isinstance(value, str):
            raise InvalidSelectorException("Invalid locator values passed in")

        return self.execute(Command.FIND_ELEMENTS,
                             {'using': by, 'value': value})['value']
开发者ID:akshay-bhardwaj,项目名称:python-webdriver,代码行数:14,代码来源:webdriver.py

示例4: find_elements

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import is_valid [as 别名]
    def find_elements(self, by=By.ID, value=None):
        if not By.is_valid(by) or not isinstance(value, str):
            raise InvalidSelectorException("Invalid locator values passed in")

        if by == By.ID:
            by = By.CSS_SELECTOR
            value = '[id="%s"]' % value
        elif by == By.TAG_NAME:
            by = By.CSS_SELECTOR
        elif by == By.CLASS_NAME:
            by = By.CSS_SELECTOR
            value = ".%s" % value
        elif by == By.NAME:
            by = By.CSS_SELECTOR
            value = '[name="%s"]' % value

        return self._execute(Command.FIND_CHILD_ELEMENTS,
                             {"using": by, "value": value})['value']
开发者ID:dimacus,项目名称:selenium,代码行数:20,代码来源:webelement.py

示例5: find_elements

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import is_valid [as 别名]
    def find_elements(self, by=By.ID, value=None):
        if not By.is_valid(by) or not isinstance(value, str):
            raise InvalidSelectorException("Invalid locator values passed in")

        return self._execute(Command.FIND_CHILD_ELEMENTS,
                             {"using": by, "value": value})['value']
开发者ID:Appdynamics,项目名称:selenium,代码行数:8,代码来源:webelement.py


注:本文中的selenium.webdriver.common.by.By.is_valid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。