我正在尝试使用 Python Selenium API 来单击按钮。 HTML代码如下:
<button class="btn wizard-next btn-primary" type="button">Weiter</button>
如何最好地识别这个元素?我正在尝试以下代码
driver.find_element_by_class_name("btn wizard-next btn-primary").click()
但出现错误
selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Compound class names not permitted
我还能做什么来选择这个元素?
最佳答案
如果类名值包含空格,则无法使用find_element_by_class_name()
。
尝试:
driver.find_element_by_xpath("//button[@class='btn wizard-next btn-primary']").click()
关于python - 如何使用 Selenium 点击按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38220902/