selenium+定位方法 findElement 之 By css
selenium+定位方法 findElement 之 By css
通过css定位:css定位有N种写法,列几个常用写法:
-
id css:
-
driver.findElement(By.cssSelector("#kw")
-
name css :
-
driver.findElement(By.cssSelector("[name=wd]")
-
className css :
-
driver.findElement(By.cssSelector(".s_ipt")
-
span css:
-
driver.findElement(By.cssSelector("span.soutu-btn> input#kw")
-
form css:
-
driver.findElement(By.cssSelector("form#form > span > input")