css定位

driver.find_elements_by_css_selector("#blog_nav_contact")#id
driver.find_elements_by_css_selector(".menu")#class
driver.find_elements_by_css_selector("a")#标签
driver.find_elements_by_css_selector("[rel='nofollow']")#其他属性
driver.find_elements_by_css_selector("type='text'")#type属性
#标签与属性的组合
driver.find_elements_by_css_selector("input:contains('kw')")
driver.find_elements_by_css_selector("input.s_ipt")#标签和class属性
driver.find_elements_by_css_selector("input#kw")#标签和id属性
driver.find_elements_by_css_selector("input[id='kw']")#标签和其他属性
driver.find_elements_by_css_selector("form#form>span>input")
driver.find_elements_by_css_selector("form.fm>span>input")
#<select id='na' name='me'>
#<option selected="" value="北京">北京</option>
#<option value="上海">上海</option>
#<option value="天津">天津</option>
#</select>
driver.find_elements_by_css_selector("select#na>option:nth-child(1)")#选择北京
driver.find_elements_by_css_selector("select#na>option:nth-child(2)")#选择上海
driver.find_elements_by_css_selector("select#na>option:nth-child(3)")#选择天津
#逻辑运算
driver.find_elements_by_css_selector("input[id='kw'][name='wd']")
posted @ 2017-07-20 22:17  至平  阅读(136)  评论(0编辑  收藏  举报