‘WebDriver‘ object has no attribute ‘find_element_by_xpath‘解决方法
结果报错:'WebDriver' object has no attribute 'find_element_by_xpath'好久没用selenium,最新由于需求重新上手之前跑的正常程序。selenium更新版本了,经一番debug之后,发现。
·
好久没用selenium,最新由于需求重新上手之前跑的正常程序
结果报错:'WebDriver' object has no attribute 'find_element_by_xpath'
经一番debug之后,发现
selenium更新版本了,
之前的写法:
wd.find_element_by_xpath('/html/body/div[3]/div[2]/div/div[1]/div[1]/div[1]/div/ul/li[2]/a')
现在的写法:
wd.find_element(By.XPATH, '/html/body/div[3]/div[2]/div/div[1]/div[1]/div[1]/div/ul/li[2]/a')
记得导入包
from selenium.webdriver.common.by import By
成功!
更多推荐
已为社区贡献6条内容
所有评论(0)