码迷,mamicode.com
首页 > 其他好文 > 详细

selenium完整例子

时间:2019-12-05 22:34:08      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:完整   cli   selenium   元素   none   col   gen   定位   str   

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)


 

 

selenium完整例子

标签:完整   cli   selenium   元素   none   col   gen   定位   str   

原文地址:https://www.cnblogs.com/angdh/p/11991967.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!