Selenium将Xpath(ID和Class)转换为CSS选择器

时间:2016-10-17 13:55:13

标签: selenium css-selectors

尝试了解如何将此Xpath转换为CSS定位器。

 //div[@id='State']//input[@class='state-dropdown list']

4 个答案:

答案 0 :(得分:1)

上面xpath的cssSelector是

div#State input.state-dropdown.list

此处# represents id. represents class name

答案 1 :(得分:1)

  

// div [@ id ='State'] //输入[@ class ='state-dropdown list']

cssSelector的有效xpath将是: -

div#State input.state-dropdown.list

From CSS Selector Reference

答案 2 :(得分:0)

div#State input.state-dropdown.list

答案 3 :(得分:0)

尝试:

div#State * > input.state-dropdown.list

有关更多参考,请访问以下链接:

http://www.w3schools.com/css/css_combinators.asp