AttributeError: 'WebDriver' object has no attribute 'find_element_by_xpath'
时间: 2023-09-15 21:23:00 浏览: 109
【Python】AttributeError: ‘AutoSchema’ object has no attribute ‘get_link’
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']")
```
阅读全文