简体   繁体   中英

Convert Xpath to CSS selector

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM