3

I am struggling in converting the follow Xpath to CSS: "//form[@id=\'giftcard-form\']/div[3]/div/button". I know I could use the Xpath for my selenium JS but it doesn't work in my case for some odd reason. I was successful in converting an easier one and using its in the script but I can't get this one right. Anyone can help?

4
  • try #giftcard-form div:nth-child(3) button Commented Nov 18, 2018 at 3:35
  • 1
    cssify.appspot.com form#giftcard-form > div:nth-of-type(3) > div > button Commented Nov 18, 2018 at 3:40
  • Welcome to SO. go through the guidelines on how to ask a good question.Help Center and how to ask question. Regarding your question paste the html snippet of the webelement that you want. Commented Nov 18, 2018 at 19:03
  • @Alok Thank you for your answer. Commented Nov 19, 2018 at 16:41

2 Answers 2

6

One should learn how to write css selectors, but a for a quick fix, try: cssify

For example, I put in your xpath and it spit out: form#giftcard-form > div:nth-of-type(3) > div > button

Btw, you had an error in your xpath, it should be this: //form[@id='giftcard-form']/div[3]/div/button

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

4 Comments

any substitute? cssify isn't working any more :/
@MarkMayo, I might be late but check again. It's working.
yep, seems back!
The link is not working, you can see error 500 in console log
2

For XPath as:

//form[@id=\'giftcard-form\']/div[3]/div/button

The equivalent CSS would be:

form#giftcard-form>div:nth-of-type(3)>div>button

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.