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


Python by.By类代码示例

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


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

示例1: find_elements

    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,代码行数:26,代码来源:webdriver.py

示例2: method

    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,代码行数:9,代码来源:config.py

示例3: find_elements

    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,代码行数:12,代码来源:webdriver.py

示例4: test_auto_write_time_for_orange_python_webdriver

 def test_auto_write_time_for_orange_python_webdriver(self):
     driver = self.driver
     driver.get(self.base_url + "/login.php")
     driver.find_element_by_name("txtUserName").clear()
     driver.find_element_by_name("txtUserName").send_keys(UserName)
     driver.find_element_by_name("txtPassword").send_keys(Password)
     driver.find_element_by_name("Submit").click()
     driver.find_element_by_link_text("Time").click()
     driver.find_element_by_link_text("Timesheets").click()          
     driver.find_element_by_id("btnEdit").click()
     row_count=driver.findElement(By.tagName("tr")).size()
     print row_count        
开发者ID:AmyOrchid188,项目名称:Knowledge,代码行数:12,代码来源:GetTableRowCount.py

示例5: find_elements

    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,代码行数:18,代码来源:webelement.py

示例6: find_elements

    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,代码行数:6,代码来源:webelement.py

示例7: get_param

    = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0'
ghost = webdriver.PhantomJS(executable_path='E:/software/phantomjs-2.1.1-windows/bin/phantomjs.exe')

def get_param( driver, url ):
    driver.get(url)
    total_txt = driver.find_element_by_id("total").text
    
    #try:
    return total_txt

if __name__ == '__main__':

    cid = 566921
    url_address = "https://iknow.jp/courses/%d"%cid
    #total = get_param(ghost,url_address)
    # f = open("record.txt","wt+",encoding="UTF-8")
    #ofile_name = "record_%d.txt"%cid
    #ofile = codecs.open(ofile_name, "w", "utf-8")
    voclist = ghost.findElements(By.xpath("//li"))
    for i in voclist:
        print(i)

    #for j in range(0, total):
    current_page = ghost.find_element_by_css_selector('.items').text
    print("current page:" + current_page)
    k = 0
    #    get_transaction_from_page(ofile, ghost, int(current_page), total)

    ghost.close()
    #ofile.close()
开发者ID:jjcc,项目名称:PythonUtilities,代码行数:30,代码来源:grab_jp.py

示例8: get_parent

 def get_parent(self):
     return self.web_element.find_element(By.xpath('..'))
开发者ID:KenjiOhtsuka,项目名称:pynium,代码行数:2,代码来源:dom_element.py

示例9: get_items

 def get_items(self) -> list:
     li_list = self.web_element.find_elements(By.xpath('/li'))
     return DomElementFactory.create_dom_element_list(li_list)
开发者ID:KenjiOhtsuka,项目名称:pynium,代码行数:3,代码来源:dom_element.py


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