Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.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 Selenium-如何点击a标签_Python_Selenium - Fatal编程技术网

Python Selenium-如何点击a标签

Python Selenium-如何点击a标签,python,selenium,Python,Selenium,我不熟悉python、webscraping和selenium,所以我的问题可能非常基本。在这里,我对类似的问题给出了很多建议,但这对我的问题没有帮助 我用selenium打开的url包含一个按钮“登录”。相应的html行如下所示: <a class="o-buttons o-buttons--big" role="button" href="https://accounts.ft.com/login?location=https%3A%2F%2Fftalphaville.ft.com%2

我不熟悉python、webscraping和selenium,所以我的问题可能非常基本。在这里,我对类似的问题给出了很多建议,但这对我的问题没有帮助

我用selenium打开的url包含一个按钮“登录”。相应的html行如下所示:

<a class="o-buttons o-buttons--big" role="button" href="https://accounts.ft.com/login?location=https%3A%2F%2Fftalphaville.ft.com%2F2012%2F07%2F27%2F1098471%2Fwhat-is-the-ecb-going-to-do-next%2F" data-trackable="sign-in">or sign in</a>
在其他人中,我试图使用

button = driver.find_element_by_xpath("//a/u[data-trackable='sign-in')]")
button.click()

但是它不起作用-有人能帮我吗

您的xpath不正确:
button=driver.通过xpath(//a[@data trackable='sign-in'])查找元素

按钮。单击()?你能粘贴网站的html源代码吗?对不起,我有问题中的html和x路径,但它没有显示在这里希望它现在能工作!就这样,非常感谢![无法在此处投票表决信誉太低的b/c]这是正确的,我正要更新我的答案。无论如何,荣誉
button = driver.find_element_by_xpath("//a/u[data-trackable='sign-in')]")
button.click()