将Xpath转换为CSS选择器 [英] Convert Xpath to CSS selector
问题描述
我正在努力将以下Xpath转换为CSS:"//form [@id = \'giftcard-form \']/div [3]/div/button". 我知道我可以将Xpath用于我的硒JS,但由于某种奇怪的原因,它在我的情况下不起作用.我成功地转换了一个简单的脚本,并在脚本中使用了它,但我无法做到这一点. 有人可以帮忙吗?
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?
推荐答案
一个人应该学习如何编写CSS选择器,但是要快速修复,请尝试:
One should learn how to write css selectors, but a for a quick fix, try: cssify
例如,我放入您的xpath并吐出:form#giftcard-form > div:nth-of-type(3) > div > button
For example, I put in your xpath and it spit out: form#giftcard-form > div:nth-of-type(3) > div > button
顺便说一句,您的xpath错误,应该是这样的://form[@id='giftcard-form']/div[3]/div/button
Btw, you had an error in your xpath, it should be this: //form[@id='giftcard-form']/div[3]/div/button
这篇关于将Xpath转换为CSS选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!