Convert Xpath to CSS selector
12,480
Solution 1
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
Solution 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
Related videos on Youtube
Author by
Samoht Rusconi
Updated on June 04, 2022Comments
-
Samoht Rusconi almost 2 years
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?
-
Tamil Selvan C over 5 yearstry
#giftcard-form div:nth-child(3) button
-
connexo over 5 yearscssify.appspot.com
form#giftcard-form > div:nth-of-type(3) > div > button
-
Alok over 5 yearsWelcome 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.
-
Samoht Rusconi over 5 years@Alok Thank you for your answer.
-
-
Mark Mayo almost 3 yearsany substitute? cssify isn't working any more :/
-
New Guy over 2 years@MarkMayo, I might be late but check again. It's working.
-
Mark Mayo over 2 yearsyep, seems back!