Python 硒-与x27之间的差异//按钮[包含(text(),“s”)和;和'//按钮[文本()[包含(,“s”)]';?
我想点击带有特殊文本的按钮 按钮看起来像Python 硒-与x27之间的差异//按钮[包含(text(),“s”)和;和'//按钮[文本()[包含(,“s”)]';?,python,selenium,xpath,Python,Selenium,Xpath,我想点击带有特殊文本的按钮 按钮看起来像 <button> <span class="totalStake">0.00</span> <span class="isocode">USD</span> <span class="freeStake"></span> Place Bet </button> xpath\u找不到元素。但是你的好是成功的。
<button>
<span class="totalStake">0.00</span> <span class="isocode">USD</span>
<span class="freeStake"></span> Place Bet
</button>
xpath\u找不到元素。但是你的好是成功的。我非常确定他们做的事情是一样的,这就是为什么我在两个多小时的时间里都没有找到另一种解决问题的方法
这些表达方式有什么区别
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("***")
...
button_text = "Place Bet"
xpath_wrong = '//button[contains(text(), "%s")]' % button_text #!!!not working
xpath_good = "//button[text()[contains(.,'%s')]]" % button_text #!!!working