【发布时间】:2020-04-18 05:26:53
【问题描述】:
所以我有 HTML 代码: enter image description here
如何点击此按钮?这个的 Xpath 是什么?
【问题讨论】:
-
即使在谷歌上也很容易找到答案。请考虑研究一个主题,然后在这里询问堆栈溢出...
-
这能回答你的问题吗? Click a button using Selenium and Python
所以我有 HTML 代码: enter image description here
如何点击此按钮?这个的 Xpath 是什么?
【问题讨论】:
该特定图像的 xPath 是
/html/body/img
点击它
driver.findElement(By.xpath("/html/body/img")).click()
【讨论】:
对于 xpath,您需要从顶层到此按钮的路径。
看起来像html\body\div\button [只是一个例子]。
您必须检查整个页面才能使用 xpath 导航到该按钮。
另一种更好的方法是使用 class="auth-button positive" 的 find 元素,然后使用 click() it
【讨论】: