AttributeError: 'WebDriver' object has no attribute 'find_element_by_xpath'
时间: 2023-09-15 13:23:00 浏览: 103
webdriver不能启动浏览器,报module ‘selenium.webdriver’ has no attribute”问题解决办法
5星 · 资源好评率100%
This error message usually occurs when you are trying to use the "find_element_by_xpath" method on a variable that is not an instance of the WebDriver class.
To resolve this issue, make sure that you have properly initialized and assigned the WebDriver object to a variable before using any of its methods, including "find_element_by_xpath".
For example, if you are using Selenium with Python, you may need to first import the WebDriver module and create a new instance of the driver:
```
from selenium import webdriver
driver = webdriver.Chrome()
# Now you can use the find_element_by_xpath method on the driver object
element = driver.find_element_by_xpath("//div[@class='example']")
```
阅读全文