当前位置: 首页>>代码示例>>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;未经允许,请勿转载。