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