selenium完整例子


driver.get("https://www.booking.com")

//通过 xpath 等待input 元素 是否 加载出来, 最大等 60s
input_blno = WebDriverWait(driver, 60).until(
        EC.presence_of_element_located((By.XPATH, """//*[@id="search-stripe"]/table/input"""))
    )



//通过 xpath 定位 元素 ,点击元素
the_butten = driver.find_element(By.XPATH, '//*[@id="ext-gen361"]/input')
the_butten.click()


//判断页面 是否 包含什么 内容
if 'DOCUMENT does not exist' in driver.page_source:
print "nononoon"
return None
//光标 移动 
//动态 找到 tr
t_d_butten = driver.find_element_by_xpath("""//*[@id="ext-gen46"]//table/tbody/tr[%s]/td[1]""" % (i + 1))
# 光标 移动到 目标位置
ActionChains(driver).move_to_element(t_d_butten).perform()
time.sleep(1)
# 点击这一行
t_d_butten.click()
time.sleep(0.5)


 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM