id定位
wb.find_element(By.ID,‘id’).send_keys(‘key’)
name定位
wb.find_element(By.NAME,‘name’).send_keys(‘key’)
link_text定位
wb.find_element(By.LINK_TEXT,‘新闻’).click()
partial_link_text定位
wb.find_element(By.PARTIAL_LINK_TEXT,‘新’).click()
xpath定位
绝对路径:/开头是绝对路径
/html/body/div[1]/…
相对路径: //开头是相对路径
//input
1,相对路径+索引定位
//form/span[1]/input
2,相对路径+属性定位
//input[@autoxxx=‘off’]
3,相对路径+通配符定位
//[@=‘xxx’]
4,相对路径+部分属性值定位
start-with 以什么开头
substring(@xxx,3)='ff’截取
contains(@xxx,‘of’) 包含
//input[start-with(@autoxxx,‘off’)]
5,相对路径+文本定位
//span[text()=‘xxx’]
css定位
003 python 元素定位
最新推荐文章于 2024-08-08 14:28:23 发布