當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。