本文整理汇总了Python中selenium.webdriver.support.wait.WebDriverWait.find_element_by_xpath方法的典型用法代码示例。如果您正苦于以下问题:Python WebDriverWait.find_element_by_xpath方法的具体用法?Python WebDriverWait.find_element_by_xpath怎么用?Python WebDriverWait.find_element_by_xpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.support.wait.WebDriverWait
的用法示例。
在下文中一共展示了WebDriverWait.find_element_by_xpath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: info_frame
# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import find_element_by_xpath [as 别名]
def info_frame(self, desigion):
time.sleep(2)
buttons = WebDriverWait(self.driver, 3).until(
EC.presence_of_element_located((By.XPATH, '//info//div[3]'))
)
if desigion == 'yes':
buttons.find_element_by_xpath('./div[1]/button').click()
elif desigion == 'no':
buttons.find_element_by_xpath('./div[2]/button').click()
示例2: google_directions_set_time_mode
# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import find_element_by_xpath [as 别名]
def google_directions_set_time_mode(driver):
"""
Sets the time mode to allow specify a date time for the request
@param driver:
"""
time_listbox = WebDriverWait(driver, MAX_TIMEOUT).until(EC.visibility_of_element_located((By.XPATH,
"//*[contains(@class,'time-anchoring-selector')]//*[@role='listbox']")))
time_listbox.click()
time_listbox.find_element_by_xpath("//div[@id=':1']").click()
示例3: Create_Position
# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import find_element_by_xpath [as 别名]
def Create_Position(self, parametr, name):
self.driver.find_element_by_id('single-button').click()
if parametr == 'Department':
self.driver.find_element_by_xpath('//workers//div[1]/div[1]/ul/li[1]/a').click()
form = WebDriverWait(self.driver, 3).until(
EC.presence_of_element_located((By.TAG_NAME, "department-action"))
)
form.find_element_by_tag_name('input').send_keys(name)
form.find_element_by_xpath('.//div[3]/div[1]/button').click()
elif parametr == 'Position':
self.driver.find_element_by_xpath('//workers//div[1]/div[1]/ul/li[2]/a').click()
form = WebDriverWait(self.driver, 3).until(
EC.presence_of_element_located((By.TAG_NAME, "role-action"))
)
form.find_element_by_tag_name('input').send_keys(name)
form.find_element_by_xpath('.//div[3]/div[1]/button').click()
elif parametr == 'Worker':
self.driver.find_element_by_xpath('//workers//div[1]/div[1]/ul/li[3]/a').click()
return name
示例4: google_directions_get_time_text
# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import find_element_by_xpath [as 别名]
def google_directions_get_time_text(driver):
"""
Gets the route time description
@param driver:
@return:
"""
# Get expanded information card
card_body_elem = WebDriverWait(driver, MAX_TIMEOUT).until(EC.visibility_of_element_located((By.XPATH,
"//*[@class='cards-card' and @role='navigation']//*[@class='cards-expanded']")))
return card_body_elem.find_element_by_xpath("//*[contains(@class, 'cards-directions-duration-value')]").text
示例5: WebDriverWait
# 需要导入模块: from selenium.webdriver.support.wait import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.wait.WebDriverWait import find_element_by_xpath [as 别名]
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
wd = webdriver.Firefox()
urladdr = "https://uc.tiup.cn/account/login?redirect_uri=https%3A%2F%2Fuc.tiup.cn%2Foauth2%2Fauthorize%3Fclient_id%3Dcn.tiup.ruc%26redirect_uri%3Dhttp%3A%2F%2Fapp.ruc.edu.cn%3A80%2Fidc%2Feducation%2Freport%2Fxscjreport%2FXscjReportAction.do%3Fmethod%253DprintXscjReport%2526xnd%253D2015-2016%2526xq%253D2%2526xh%253D2013201375%2526redirect_uri%253Dhttp%3A%2F%2Fapp.ruc.edu.cn%3A80%2Fidc%2Feducation%2Freport%2Fxscjreport%2FXscjReportAction.do%3Fmethod%25253DprintXscjReport%252526xnd%25253D2015-2016%252526xq%25253D2%252526xh%25253D2013201375%26response_type%3Dcode%26scope%3Dall%26state%3D0.8461759818958479%3A0.6265973001333563%26theme%3Dschools%26school_code%3Druc%26sso%3Dtrue&school_code=ruc&theme=schools"
wd.get(urladdr)
try:
email = WebDriverWait(wd,timeout=10).until(EC.presence_of_element_located((By.ID,'username')),message=u'element load out of time')
email.send_keys("2013201375")
passwd = WebDriverWait(wd,timeout=10).until(EC.presence_of_element_located((By.ID,'password')),message=u'element load out of time')
passwd.send_keys("220106199408129218")
wd.find_element_by_xpath("//input[@value='登录']").click()
except NoSuchElementException as e:
print(e.message)
somedom = WebDriverWait(wd,60).until(lambda brow: brow.find_elements_by_tag_name("table"))[0]
data = somedom.find_element_by_xpath("//*").get_attribute("outerHTML")
fp = open("web.txt",'w')
fp.write(data)
fp.close()