我编写了一个脚本,并且能够为具有 html 的按钮进行编码,但是我在此链接上检查的这个按钮没有。
这是登录按钮的元素。
<input type="submit" value="login" class="button">
我如何编写这行脚本来使用 selenium 和 python 单击此按钮?
最佳答案
要单击文本为登录的按钮,您可以使用以下代码行:
browser.find_element_by_xpath("//form[@method='post' and @action='/auth/login/']//input[@class='button' and @value='login']").click()
#or
browser.find_element_by_xpath("//form[@method='post' and @action='/auth/login/']//input[@class='button' and @value='login']").submit()
关于javascript - 如何使用 Python Selenium 单击没有 ID 或 HTML 的按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49230389/