[英]Convert Xpath to CSS selector
I am struggling in converting the follow Xpath to CSS: "//form[@id=\\'giftcard-form\\']/div[3]/div/button". 我正在努力将以下Xpath转换为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. 我知道我可以将Xpath用于我的硒JS,但是由于某些奇怪的原因,它在我的情况下不起作用。 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: 对于XPath为:
//form[@id=\'giftcard-form\']/div[3]/div/button
The equivalent CSS would be: 等效的CSS将是:
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 应该学习如何编写css选择器,但是要快速修复,请尝试: cssify
For example, I put in your xpath and it spit out: form#giftcard-form > div:nth-of-type(3) > div > button
例如,我放入您的xpath并吐出: 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
顺便说一句,您的xpath错误,应该是这样的: //form[@id='giftcard-form']/div[3]/div/button
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.