最近在学自动化,但是点击登录这个按钮运行不了
//python代码
driver.implicitly_wait(20)
Denglu= driver.find_element(By.XPATH, "//button[@id=‘signin-submit-button’]")
# print(Sale)
Denglu.click()
//页面代码
selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression //button[@id=‘signin-submit-button’] because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//button[@id=‘signin-submit-button’]' is not a valid XPath expression.
(Session info: chrome=105.0.5195.127)
使用了id、xpath等多个定位元素的方法,解释器始终定位不到
能正常点击
//button[@id=‘signin-submit-button’]这个东西不是能够被识别的xpath。建议你使用Selenium IDE插件录制一下,然后把录到的路径放进去就可以了,很方便
不知道你这个问题是否已经解决, 如果还没有解决的话: