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


Python By.TAG_NAME属性代码示例

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


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

示例1: test_view_data_button

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import TAG_NAME [as 别名]
def test_view_data_button(self):
        self.get('/')

        self.wait_for_element(
            'tr.odd:nth-child(1) > td:nth-child(5) > a:nth-child(1)',
            by=By.CSS_SELECTOR
        )
        self.click(self.drv.find_element_by_css_selector(
            'tr.odd:nth-child(1) > td:nth-child(5) > a:nth-child(1)'
        ))

        self.wait_for_element('h3', by=By.TAG_NAME)
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'Survey Data'
        ) 
开发者ID:SEL-Columbia,项目名称:dokomoforms,代码行数:18,代码来源:test_selenium.py

示例2: test_content

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import TAG_NAME [as 别名]
def test_content(self):
        # Wait until baton is ready
        wait = WebDriverWait(self.driver, 10)
        wait.until(element_has_css_class((By.TAG_NAME, 'body'), "baton-ready"))

        # page title
        page_title = self.driver.find_element_by_css_selector(
            "#content h1")
        self.assertEqual(page_title.get_attribute('innerHTML'), 'Baton administration')
        self.assertEqual(page_title.is_displayed(), True)

        # recent actions
        recent_actions = self.driver.find_element_by_id('recent-actions-module')
        self.assertEqual(recent_actions.is_displayed(), True)

        modules = self.driver.find_elements_by_css_selector(
            "#content-main .module")
        self.assertEqual(len(modules), 3) 
开发者ID:otto-torino,项目名称:django-baton,代码行数:20,代码来源:test_e2e_index_mobile.py

示例3: scan_webdriver

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import TAG_NAME [as 别名]
def scan_webdriver(self):
        self.browser.get(self.entry_url)

        try:
            WebDriverWait(self.browser, 30).until(
                EC.presence_of_element_located((By.TAG_NAME, "body"))
            )
        except TimeoutException as e:
            messages.error(self.request, e)

        self.browser.delete_all_cookies()
        self.browser.add_cookie(self.wtm_cookie)
        self.browser.add_cookie(self.wtm_debug_cookie)
        self.browser.get(self.entry_url)

        for cookie in self.browser.get_cookies():
            self.process_webdriver_cookie(cookie)

        self.browser.quit() 
开发者ID:jberghoef,项目名称:wagtail-tag-manager,代码行数:21,代码来源:webdriver.py

示例4: kktix_captcha_text_value

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import TAG_NAME [as 别名]
def kktix_captcha_text_value(captcha_inner_div):
    ret = ""

    if captcha_inner_div is not None:
        try:
            captcha_password_text = captcha_inner_div.find_element(By.TAG_NAME, "input")
            if not captcha_password_text is None:
                ret = captcha_password_text.get_attribute('value')
            else:
                print("find captcha input field fail")
        except Exception as exc:
            print("find captcha_inner_div Exception:")
            #print(exc)
            pass
                
    return ret 
开发者ID:max32002,项目名称:tixcraft_bot,代码行数:18,代码来源:chrome_tixcraft.py

示例5: test_filter

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import TAG_NAME [as 别名]
def test_filter(self):
        # Wait until baton is ready
        wait = WebDriverWait(self.driver, 10)
        wait.until(element_has_css_class((By.TAG_NAME, 'body'), "baton-ready"))
        time.sleep(2)
        rows = self.driver.find_elements_by_css_selector(
            '#result_list tbody tr')
        self.assertEqual(len(rows), 3)
        filter_button = self.driver.find_element_by_css_selector(
            '.changelist-filter-toggler')
        filter_button.click()
        input = self.driver.find_element_by_css_selector(
            '#changelist-filter-modal input')
        input.send_keys('super')
        input.send_keys(Keys.RETURN)
        rows = self.driver.find_elements_by_css_selector(
            '#result_list tbody tr')
        self.assertEqual(len(rows), 2) 
开发者ID:otto-torino,项目名称:django-baton,代码行数:20,代码来源:test_e2e_input_filter.py

示例6: for_each_frame

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import TAG_NAME [as 别名]
def for_each_frame(self):
        self.driver.switch_to.default_content()

        seen_ids = set()
        def helper(nesting_level=0):
            def handle_frames(frames):
                frames = [f for f in frames if f.id not in seen_ids]
                seen_ids.update(f.id for f in frames)
                for frame in frames:
                    self.driver.switch_to.frame(frame)
                    yield from helper(nesting_level=nesting_level + 1)
                    self.driver.switch_to.parent_frame()
            yield
            for element_name in ['frame', 'iframe']:
                try:
                    other_frames = self.find_visible_elements(
                        By.TAG_NAME, element_name)
                    yield from handle_frames(other_frames)
                except:
                    pass

        yield from helper() 
开发者ID:jbms,项目名称:finance-dl,代码行数:24,代码来源:scrape_lib.py

示例7: getFormElements

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import TAG_NAME [as 别名]
def getFormElements():
    """
    Mendapatkan daftar ``form`` element, dari halaman situs.
    """

    elems = waitingResult(visibility_of_all_elements_located, By.TAG_NAME, "form") or []
    return elems 
开发者ID:brutemap-dev,项目名称:brutemap,代码行数:9,代码来源:core.py

示例8: connect_to_webpage

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import TAG_NAME [as 别名]
def connect_to_webpage(self):
        url_target_sg = 'http://railway1.hinet.net/csearch.htm'
        url_target_gb = 'http://railway.hinet.net/ctkind2.htm'
        self.driver.delete_all_cookies()
        
        wait = WebDriverWait(self.driver, timeout=6)
        try:
            # Booking Single Ticket.
            if self.book_type == 1:
                self.driver.get(url_target_sg)
                wait.until(
                    EC.presence_of_element_located(
                        (By.TAG_NAME, 'button')
                    )
                )
            # Booking Go-Back Ticket.
            elif self.book_type == 2:
                self.driver.get(url_target_gb)
                wait.until(
                    EC.presence_of_element_located(
                        (By.TAG_NAME, 'button')
                    )
                )
        except:
            self.label_show_result.setText(
                '【連線逾時或是網路不穩定】\n' + 
                '【請檢查網路環境以及是否為尖峰時段。】'
            ) 
开发者ID:gw19,项目名称:TRA-Ticket-Booker,代码行数:30,代码来源:TraTicketBooker.py

示例9: find_element

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import TAG_NAME [as 别名]
def find_element(self, by: str = By.ID, value: Union[str, Dict] = None) -> T:
        """Find an element given a By strategy and locator

        Override for Appium

        Prefer the find_element_by_* methods when possible.

        Args:
            by: The strategy
            value: The locator

        Usage:
            element = element.find_element(By.ID, 'foo')

        Returns:
            `appium.webdriver.webelement.WebElement`
        """
        # TODO: If we need, we should enable below converter for Web context
        # 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(RemoteCommand.FIND_CHILD_ELEMENT,
                             {"using": by, "value": value})['value'] 
开发者ID:appium,项目名称:python-client,代码行数:35,代码来源:webelement.py

示例10: find_elements

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import TAG_NAME [as 别名]
def find_elements(self, by: str = By.ID, value: Union[str, Dict] = None) -> List[T]:
        """Find elements given a By strategy and locator

        Override for Appium

        Prefer the find_elements_by_* methods when possible.

        Args:
            by: The strategy
            value: The locator

        Usage:
            element = element.find_elements(By.CLASS_NAME, 'foo')

        Returns:
            :obj:`list` of :obj:`appium.webdriver.webelement.WebElement`
        """
        # TODO: If we need, we should enable below converter for Web context
        # 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(RemoteCommand.FIND_CHILD_ELEMENTS,
                             {"using": by, "value": value})['value'] 
开发者ID:appium,项目名称:python-client,代码行数:35,代码来源:webelement.py

示例11: find_element

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import TAG_NAME [as 别名]
def find_element(self, by: str = By.ID, value: Union[str, Dict] = None) -> MobileWebElement:
        """'Private' method used by the find_element_by_* methods.

        Override for Appium

        Usage:
            Use the corresponding find_element_by_* instead of this.

        Returns:
            `appium.webdriver.webelement.WebElement`: The found element

        """
        # TODO: If we need, we should enable below converter for Web context
        # 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(RemoteCommand.FIND_ELEMENT, {
            'using': by,
            'value': value})['value'] 
开发者ID:appium,项目名称:python-client,代码行数:31,代码来源:webdriver.py

示例12: find_elements

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

        Override for Appium

        Usage:
            Use the corresponding find_elements_by_* instead of this.

        Returns:
            :obj:`list` of :obj:`appium.webdriver.webelement.WebElement`: The found elements
        """
        # TODO: If we need, we should enable below converter for Web context
        # 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 empty list if driver returns null
        # See https://github.com/SeleniumHQ/selenium/issues/4555

        return self.execute(RemoteCommand.FIND_ELEMENTS, {
            'using': by,
            'value': value})['value'] or [] 
开发者ID:appium,项目名称:python-client,代码行数:34,代码来源:webdriver.py

示例13: login_inactive

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import TAG_NAME [as 别名]
def login_inactive(self, username, password):
        self.test.click_through(self.setup(username, password),
                                (By.TAG_NAME, 'h1')) 
开发者ID:Cadasta,项目名称:cadasta-platform,代码行数:5,代码来源:Login.py

示例14: element_with_tag_name_has_text

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import TAG_NAME [as 别名]
def element_with_tag_name_has_text(self, tag_name, text, timeout=DEFAULT_TIMEOUT):
        return WebDriverWait(self.driver, timeout).until(
            ec.text_to_be_present_in_element((By.TAG_NAME, tag_name), text)
        ) 
开发者ID:stefanhoelzl,项目名称:vue.py,代码行数:6,代码来源:conftest.py

示例15: element_with_tag_name_present

# 需要导入模块: from selenium.webdriver.common.by import By [as 别名]
# 或者: from selenium.webdriver.common.by.By import TAG_NAME [as 别名]
def element_with_tag_name_present(self, tag, timeout=DEFAULT_TIMEOUT):
        return WebDriverWait(self.driver, timeout).until(
            ec.presence_of_element_located((By.TAG_NAME, tag))
        ) 
开发者ID:stefanhoelzl,项目名称:vue.py,代码行数:6,代码来源:conftest.py


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