當前位置: 首頁>>代碼示例>>Python>>正文


Python expected_conditions.text_to_be_present_in_element方法代碼示例

本文整理匯總了Python中selenium.webdriver.support.expected_conditions.text_to_be_present_in_element方法的典型用法代碼示例。如果您正苦於以下問題:Python expected_conditions.text_to_be_present_in_element方法的具體用法?Python expected_conditions.text_to_be_present_in_element怎麽用?Python expected_conditions.text_to_be_present_in_element使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在selenium.webdriver.support.expected_conditions的用法示例。


在下文中一共展示了expected_conditions.text_to_be_present_in_element方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: index_page

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element [as 別名]
def index_page(page):
    try:
        print('正在爬取第: %s 頁' % page)
        wait.until(
            EC.presence_of_element_located((By.ID, "dt_1")))
        # 判斷是否是第1頁,如果大於1就輸入跳轉,否則等待加載完成。
        if page > 1:
            # 確定頁數輸入框
            input = wait.until(EC.presence_of_element_located(
                (By.XPATH, '//*[@id="PageContgopage"]')))
            input.click()
            input.clear()
            input.send_keys(page)
            submit = wait.until(EC.element_to_be_clickable(
                (By.CSS_SELECTOR, '#PageCont > a.btn_link')))
            submit.click()
            time.sleep(2)
        # 確認成功跳轉到輸入框中的指定頁
        wait.until(EC.text_to_be_present_in_element(
            (By.CSS_SELECTOR, '#PageCont > span.at'), str(page)))
    except Exception:
        return None 
開發者ID:makcyun,項目名稱:eastmoney_spider,代碼行數:24,代碼來源:eastmoney_crawler.py

示例2: wait_for_text

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element [as 別名]
def wait_for_text(driver, el_id, value, removed=False, timeout=10):
    el = wait_for_element(driver, el_id, timeout)
    if value in el.text and not removed:
        return el
    if removed and value not in el.text:
        return el

    wait = WebDriverWait(driver, timeout)
    condition = EC.text_to_be_present_in_element((By.ID, el_id), value)
    if removed:
        wait.until_not(condition)
        if value not in el.text:
            return el
    else:
        wait.until(condition)
        if value in el.text:
            return el

    raise AttributeError 
開發者ID:Dallinger,項目名稱:Dallinger,代碼行數:21,代碼來源:pytest_dallinger.py

示例3: wait_for_text

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element [as 別名]
def wait_for_text(self, selector='', text='', **kwargs):
        '''
        Wait for an element to contain a specific string.

        Parameters
        ----------
        selector: str
            A CSS selector to search for. This can be any valid CSS selector.

        text: str
            The string to look for. This must be precise.
            (Case, punctuation, UTF characters... etc.)
        kwargs:
            Passed on to _wait_for

        '''
        if selector.startswith('/'):
            by = By.XPATH
        else:
            by = By.CSS_SELECTOR
        self._wait_for(EC.text_to_be_present_in_element((by, selector),
                                                        text), **kwargs) 
開發者ID:IntuitiveWebSolutions,項目名稱:PyWebRunner,代碼行數:24,代碼來源:WebRunner.py

示例4: create_attribute

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element [as 別名]
def create_attribute(self, attribute_key, attribute_value):
        # Click in the new attribute dialog
        self.selenium.find_element_by_class_name('js-attribute-create').click()
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element((By.CLASS_NAME, 'modal-title'),
                'Create attribute')
        )

        # Fill out the form
        element = self.selenium.find_element_by_id('id_key')
        element.clear()
        element.send_keys(attribute_key)
        element = self.selenium.find_element_by_id('id_attr_value')
        element.clear()
        element.send_keys(attribute_value)

        # Click in the create attribute button
        self.selenium.find_element_by_xpath(
            '//div[@class="modal-footer"]/button[normalize-space()="Create '
            'attribute"]'
        ).click()

        # Wait for modal to close and for table to refresh
        self.wait_close_modal_refresh_table('attribute-table_previous') 
開發者ID:abelardopardo,項目名稱:ontask_b,代碼行數:26,代碼來源:__init__.py

示例5: delete_filter

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element [as 別名]
def delete_filter(self):
        # First make sure we are in the filter tab
        self.select_filter_tab()

        # Click in the delete Icon
        self.selenium.find_element_by_class_name('js-filter-delete').click()
        # Wait for the confirmation screen
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, '//div[@id="modal-item"]/div/div/form/div/h4'),
                'Confirm filter deletion')
        )

        # Click in the 'delete filter'
        self.selenium.find_element_by_xpath(
            '//div[@id="modal-item"]//button[normalize-space()="Delete filter"]'
        ).click()
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        )
        self.wait_for_page(element_id='edit-personalized-text-tab-content') 
開發者ID:abelardopardo,項目名稱:ontask_b,代碼行數:23,代碼來源:__init__.py

示例6: enter_concert

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element [as 別名]
def enter_concert(self):
        self.login()
        try:
            if self.type == 1:  # detail.damai.cn
                locator = (By.XPATH, "/html/body/div[1]/div/div[3]/div[1]/a[2]/div")
            elif self.type == 2:  # piao.damai.cn
                locator = (By.XPATH, "/html/body/div[1]/div/ul/li[2]/div/label/a[2]")
            WebDriverWait(self.driver, self.total_wait_time, self.refresh_wait_time).until(
                EC.text_to_be_present_in_element(locator, self.nick_name))
            self.status = 1
            print("###登錄成功###")
        except Exception as e:
            print(e)
            self.status = 0
            self.driver.quit()
            raise Exception("***錯誤:登錄失敗,請檢查配置文件昵稱或刪除cookie.pkl後重試***") 
開發者ID:Entromorgan,項目名稱:Autoticket,代碼行數:18,代碼來源:Autoticket.py

示例7: wait_for_text

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element [as 別名]
def wait_for_text(self, css_selector, text, timeout=10):
        """
        Helper function that blocks until the text is found in the CSS selector.
        """
        from selenium.webdriver.common.by import By
        from selenium.webdriver.support import expected_conditions as ec
        self.wait_until(
            ec.text_to_be_present_in_element(
                (By.CSS_SELECTOR, css_selector), text),
            timeout
        ) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:13,代碼來源:tests.py

示例8: wait_for_text

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element [as 別名]
def wait_for_text(self, css_selector, text, timeout=10):
        """
        Block until the text is found in the CSS selector.
        """
        from selenium.webdriver.common.by import By
        from selenium.webdriver.support import expected_conditions as ec
        self.wait_until(
            ec.text_to_be_present_in_element(
                (By.CSS_SELECTOR, css_selector), text),
            timeout
        ) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:13,代碼來源:tests.py

示例9: next_page

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element [as 別名]
def next_page(self):
        next_btn = self.driver.find_element_by_css_selector('button.next')
        next_btn.click()
        self.wait(EC.text_to_be_present_in_element(
            (By.CSS_SELECTOR, '.results-paginator li.page-list li.active'), str(self.page_num + 1)
        ))
        self.page_num += 1 
開發者ID:austinoboyle,項目名稱:scrape-linkedin-selenium,代碼行數:9,代碼來源:ConnectionScraper.py

示例10: configure_connection_type

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element [as 別名]
def configure_connection_type(self):
        dropdown_btn = self.wait_for_el(
            '.search-s-facet--facetNetwork form button')
        if not self.first_only:
            return
        new_url = re.sub(r'&facetNetwork=(.*?)&',
                         r'&facetNetwork=%5B"F"%5D&', self.driver.current_url)
        self.driver.get(new_url)
        self.wait(EC.text_to_be_present_in_element(
            (By.CSS_SELECTOR, '.search-s-facet--facetNetwork'), '1st'
        )) 
開發者ID:austinoboyle,項目名稱:scrape-linkedin-selenium,代碼行數:13,代碼來源:ConnectionScraper.py

示例11: element_has_text

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element [as 別名]
def element_has_text(self, id_, text, timeout=DEFAULT_TIMEOUT):
        return WebDriverWait(self.driver, timeout).until(
            ec.text_to_be_present_in_element((By.ID, id_), text)
        ) 
開發者ID:stefanhoelzl,項目名稱:vue.py,代碼行數:6,代碼來源:conftest.py

示例12: element_with_tag_name_has_text

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element [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

示例13: next_page

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element [as 別名]
def next_page(page_num):
    try:
        print('獲取下一頁數據')
        next_btn = WAIT.until(EC.element_to_be_clickable((By.CSS_SELECTOR, '#server-search-app > div.contain > div.body-contain > div > div.page-wrap > div > ul > li.page-item.next > button')))
        next_btn.click()
        WAIT.until(EC.text_to_be_present_in_element((By.CSS_SELECTOR, '#server-search-app > div.contain > div.body-contain > div > div.page-wrap > div > ul > li.page-item.active > button'),str(page_num)))
        get_source()
    except TimeoutException:
        browser.refresh()
        return next_page(page_num) 
開發者ID:yzy1996,項目名稱:Python-Code,代碼行數:12,代碼來源:caixukun.py

示例14: next_page

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element [as 別名]
def next_page(page_num):
    try:
        print('獲取下一頁數據')
        next_btn = WAIT.until(EC.element_to_be_clickable((By.CSS_SELECTOR,
                                                          '#all-list > div.flow-loader > div.page-wrap > div > ul > li.page-item.next > button')))
        next_btn.click()
        WAIT.until(EC.text_to_be_present_in_element((By.CSS_SELECTOR,
                                                     '#all-list > div.flow-loader > div.page-wrap > div > ul > li.page-item.active > button'),
                                                    str(page_num)))
        get_source()
    except TimeoutException:
        browser.refresh()
        return next_page(page_num) 
開發者ID:wistbean,項目名稱:learn_python3_spider,代碼行數:15,代碼來源:ikun_basketball.py

示例15: delete_condition

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element [as 別名]
def delete_condition(self, cname):
        """
        Given a condition name, search for it in the right DIV and click the
        buttons to remove it.
        :param cname: Condition name
        :return:
        """
        self.select_condition_tab()

        # Get the button for the condition
        self.selenium.find_element_by_xpath(
            '//*[contains(@class, "card-header") and text() = "{0}"]/'
            '../div[@class = "cond-buttons"]/'
            'button[contains(@class, "js-condition-delete")]'.format(cname),
        ).click()
        # Wait for the screen to delete the condition
        WebDriverWait(self.selenium, 10).until(
            EC.text_to_be_present_in_element(
                (By.XPATH, '//div[@id="modal-item"]/div/div/form/div/h4'),
                'Confirm condition deletion')
        )

        # Click in the confirm button
        self.selenium.find_element_by_xpath(
            '//div[@id="modal-item"]//button[normalize-space()="Delete '
            'condition"]'
        ).click()
        self.wait_for_page(element_id='edit-personalized-text-tab-content') 
開發者ID:abelardopardo,項目名稱:ontask_b,代碼行數:30,代碼來源:__init__.py


注:本文中的selenium.webdriver.support.expected_conditions.text_to_be_present_in_element方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。