2

Trying to understand how to convert this Xpath to CSS locator.

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

4 Answers 4

1

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

The valid cssSelector for this xpath would be :-

div#State input.state-dropdown.list

From CSS Selector Reference

  • CSS #id Selector use to locate an element with their id attribute value

  • CSS element element Selector use to locate element that is inside paranet element. In your case, cssSelector would be locate <input> elements that would be inside <div> element.

  • CSS .class Selector use to locate an element with their class attribute value

Sign up to request clarification or add additional context in comments.

Comments

1

the cssSelector for above xpath is

div#State input.state-dropdown.list

here # represents id and . represents class name.

Comments

0
div#State input.state-dropdown.list

Comments

0

Try with:

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

For more reference follow the link:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.