Python and Selenium XPath locator methods in detail
发布时间
阅读量:
阅读量
前言
本文将围绕selenium中的xpath定位方式进行探讨。众所周知,selenium提供了八种元素定位方式,包括id、name、class name、tag name、link text、partial link text、xpath以及css。本次内容将重点解析这八种定位方式中xpath的应用方法,接下来我们直接进入正题。

一、xpath基本定位用法
1.1 通过元素ID进行定位 -- driver.find_element_by_xpath('//input[@id="kw"]')

1.2 通过class属性进行元素定位 -- driver.find_element_by_xpath('//input[@class="s_ipt"]')

还没有任何评论哟~
