Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 硒-与x27之间的差异//按钮[包含(text(),“s”)和;和'//按钮[文本()[包含(,“s”)]';?_Python_Selenium_Xpath - Fatal编程技术网

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>&nbsp;Place Bet </button> xpath\u找不到元素。但是你的好是成功的。

我想点击带有特殊文本的按钮

按钮看起来像

    <button>
    <span class="totalStake">0.00</span> <span class="isocode">USD</span> 
    <span class="freeStake"></span>&nbsp;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