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


Python expected_conditions.title_contains方法代码示例

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


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

示例1: wait_until_title_contains_keyword

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_contains [as 别名]
def wait_until_title_contains_keyword(self):
        try:
            WebDriverWait(self.webdriver, 5).until(EC.title_contains(self.query))
        except TimeoutException:
            logger.debug(SeleniumSearchError(
                '{}: Keyword "{}" not found in title: {}'.format(self.name, self.query, self.webdriver.title))) 
开发者ID:ecoron,项目名称:SerpScrap,代码行数:8,代码来源:selenium.py

示例2: check_order_1

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_contains [as 别名]
def check_order_1(self):
        if self.status in [3, 4]:
            print('###开始确认订单###')
            button_xpath = " //*[@id=\"confirmOrder_1\"]/div[%d]/button" # 同意以上协议并提交订单Xpath
            button_replace = 8 # 当实名者信息不空时为9,空时为8
            if self.real_name: # 实名者信息不为空
                button_replace = 9
                print('###选择购票人信息###')
                try:
                    list_xpath = "//*[@id=\"confirmOrder_1\"]/div[2]/div[2]/div[1]/div[%d]/label/span[1]/input"
                    for i in range(len(self.real_name)): # 选择第i个实名者
                        WebDriverWait(self.driver, self.total_wait_time, self.refresh_wait_time).until(
                            EC.presence_of_element_located((By.XPATH, list_xpath%(i+1)))).click()
                except Exception as e:
                    print(e)
                    raise Exception("***错误:实名信息框未显示,请检查网络或配置文件***")
            submitbtn = WebDriverWait(self.driver, self.total_wait_time, self.refresh_wait_time).until(
                    EC.presence_of_element_located(
                        (By.XPATH, button_xpath%button_replace))) # 同意以上协议并提交订单
            submitbtn.click()  
            '''# 以下的方法更通用,但是更慢
            try:
                buttons = self.driver.find_elements_by_tag_name('button') # 找出所有该页面的button
                for button in buttons:
                    if button.text == '同意以上协议并提交订单':
                        button.click()
                        break
            except Exception as e:
                raise Exception('***错误:没有找到提交订单按钮***')
           '''
            try:
                WebDriverWait(self.driver, self.total_wait_time, self.refresh_wait_time).until(
                    EC.title_contains('支付宝'))
                self.status = 6
                print('###成功提交订单,请手动支付###')
                self.time_end = time()
            except Exception as e:
                print('---提交订单失败,请查看问题---')
                print(e) 
开发者ID:Entromorgan,项目名称:Autoticket,代码行数:41,代码来源:Autoticket.py

示例3: check_order_2

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_contains [as 别名]
def check_order_2(self):
        if self.status in [3, 4]:
            print('###开始确认订单###')
            if self.real_name: # 实名者信息不为空
                print('###选择购票人信息###')
                try:
                    tb = WebDriverWait(self.driver, self.total_wait_time, self.refresh_wait_time).until(
                        EC.presence_of_element_located(
                        (By.CLASS_NAME, 'from-1')))
                    tb.find_element_by_tag_name('a').click() # 点击选择购票人按钮
                    
                    sleep(self.intersect_wait_time)
                    # 此处好像定位不到实名者框,还没有解决
                    lb_list = WebDriverWait(self.driver, self.total_wait_time, self.refresh_wait_time).until(
                        EC.presence_of_element_located(
                        (By.XPATH, '/html/body/div[3]/div[3]/div[12]/div/div[2]/div/div[2]/div/table/tbody'))) # 定位弹窗
                    lb = lb_list.find_elements_by_tag_name('input')
                    for i in range(len(self.real_name)):
                        lb[self.real_name[i] - 1].find_element_by_tag_name('input').click()  # 选择第self.real_name个实名者
                except Exception as e:
                    print(e)
            input('halt')
            WebDriverWait(self.driver, self.total_wait_time, self.refresh_wait_time).until(
                        EC.presence_of_element_located(
                        (By.ID, 'orderConfirmSubmit'))).click() # 同意以上协议并提交订单
            # self.driver.find_element_by_id('orderConfirmSubmit').click() 
            element = WebDriverWait(self.driver, 10, self.refresh_wait_time).until(EC.title_contains('选择支付方式'))
            element.find_element_by_xpath('/html/body/div[5]/div/div/div/ul/li[2]/a').click()  # 默认选择支付宝
            element.find_element_by_xpath('/html/body/div[5]/div/div/form/div[2]/ul/li[1]/label/input').click()
            element.find_element_by_id('submit2').click()  # 确认无误,支付
            self.status = 6
            print('###成功提交订单,请手动支付###')
            self.time_end = time()
            # print('###提交订单失败,请查看问题###') # 这里异常处理还有点问题 
开发者ID:Entromorgan,项目名称:Autoticket,代码行数:36,代码来源:Autoticket.py

示例4: login_to_sketchfab

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_contains [as 别名]
def login_to_sketchfab(browser, user=None, pwd=None):
    #Login to sketchfab
    browser.get("http://sketchfab.com/login")
    if user is not None and pwd is not None:
        browser.find_element_by_id("email").send_keys(user)
        browser.find_element_by_id("password").send_keys(pwd)
        browser.find_element_by_css_selector(".form-button").click()
    try:
        WebDriverWait(browser, 120).until(EC.title_contains("Profile"))
    finally:
        pass 
开发者ID:norgeotloic,项目名称:BakeMyScan,代码行数:13,代码来源:sketchfab_download_models.py

示例5: wait_for_title_contains

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_contains [as 别名]
def wait_for_title_contains(self, partial_title, timeout):
        """Wait for page title to contain partial_title

        :Args:
        - partial_title: expected partial title
        - timeout: time to wait (in seconds)
        """
        wait = WebDriverWait(self, timeout)
        message = 'Timeout waiting for title to contain \'{}\''.format(partial_title)
        wait.until(ec.title_contains(partial_title), message=message) 
开发者ID:golemhq,项目名称:golem,代码行数:12,代码来源:extended_driver.py

示例6: wait_for_title_not_contains

# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_contains [as 别名]
def wait_for_title_not_contains(self, partial_title, timeout):
        """Wait for page title to not contain partial_title

        :Args:
        - partial_title: not expected partial title
        - timeout: time to wait (in seconds)
        """
        wait = WebDriverWait(self, timeout)
        message = 'Timeout waiting for title to not contain \'{}\''.format(partial_title)
        wait.until_not(ec.title_contains(partial_title), message=message) 
开发者ID:golemhq,项目名称:golem,代码行数:12,代码来源:extended_driver.py


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