css_selector和xpath的路径定位
css_selector路径定位原理,先定位第一个,然后在加一个,表示第二个,css_selector如下
brower.find_element_by_css_selector('table>tbody#plan_list>tr+tr>td>input[type="checkbox"]').click()
写成by_xpath如下
brower.find_element_by_xpath('//table/tbody[@id="plan_list"]/tr[2]/td/input[type="checkbox"]').click()
css_selector如下
brower.find_element_by_css_selector('table>tbody#plan_list>tr+tr+tr>td>input[type="checkbox"]').click()
写成by_xpath如下
brower.find_element_by_xpath('//table/tbody[@id="plan_list"]/tr[3]/td/input[type="checkbox"]').click()
有时候用by_xpath会出现如下报错,应该用css_selector
could not be scrolled into view