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

selenium 常用总结

时间:2015-10-28 19:38:12      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:selenium

去tr里面的内容

text = driver.find_elements_by_xpath("//table[@id=‘trackTable‘]")

for i in text:

  print i.text




#下拉框

#Select(driver.find_element_by_id("set_start_hour_scan")).select_by_index(3)

#Select(driver.find_element_by_id("set_start_hour_scan")).select_by_value("11")

#Select(driver.find_element_by_id("set_start_hour_scan")).select_by_visible_text("18")


xpath常用的复杂方法

1. 使用starts-with

//div[starts-with(@id,‘aaaa‘)]//table//tr//td[2]//table//tr//td//a//span[contains(.,‘fffffffff‘)]

2.使用contains和and

//div[starts-with(@id,‘res‘)]//table[1]//tr//td[2]//a//span[contains(.,‘ffffffffft‘) and contains(.,‘fffffffff‘)]

3.使用descendant

//div[starts-with(@id,‘res‘)]//table[1]//tr//td[2]//a//span[contains(.,‘QuickStart‘)]/../../../descendant::img

4.使用ancestor

//div[starts-with(@id,‘res‘)]//table[1]//tr//td[2]//a//span[contains(.,‘QuickStart‘)]/ancestor::div[starts-with(@id,‘res‘)]//table[2]//descendant::a[2]

5.使用text()

//span[@id=‘idHeaderTitleCell‘ and contains(text(),‘QuickStart‘)]


本文出自 “tabsang成长历程” 博客,转载请与作者联系!

selenium 常用总结

标签:selenium

原文地址:http://tabsang.blog.51cto.com/6647507/1707349

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