Python selenium.webdriver.support.expected_conditions.title_contains() Examples
The following are 6
code examples of selenium.webdriver.support.expected_conditions.title_contains().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
selenium.webdriver.support.expected_conditions
, or try the search function
.
Example #1
Source File: selenium.py From SerpScrap with MIT License | 5 votes |
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)))
Example #2
Source File: Autoticket.py From Autoticket with MIT License | 5 votes |
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)
Example #3
Source File: Autoticket.py From Autoticket with MIT License | 5 votes |
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('###提交订单失败,请查看问题###') # 这里异常处理还有点问题
Example #4
Source File: sketchfab_download_models.py From BakeMyScan with GNU General Public License v3.0 | 5 votes |
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
Example #5
Source File: extended_driver.py From golem with MIT License | 5 votes |
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)
Example #6
Source File: extended_driver.py From golem with MIT License | 5 votes |
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)