selenium+定位方法 findElement 之 By css

selenium+定位方法 findElement 之 By css

通过css定位:css定位有N种写法,列几个常用写法:

  1. id css:
  2. driver.findElement(By.cssSelector("#kw")
  3. name css :
  4. driver.findElement(By.cssSelector("[name=wd]")
  5. className css :
  6. driver.findElement(By.cssSelector(".s_ipt")
  7. span css:
  8. driver.findElement(By.cssSelector("span.soutu-btn> input#kw")
  9. form css:
  10. driver.findElement(By.cssSelector("form#form > span > input")
posted @ 2024-02-03 21:07  大白熊^_^  阅读(50)  评论(0编辑  收藏  举报