AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'
时间: 2023-09-21 11:03:17 浏览: 214
This error occurs when you try to use the "find_element_by_id" method on an instance of the WebDriver class, which does not have this method.
To fix this error, you need to create an instance of the WebElement class by finding the element with the "find_element_by_id" method on an instance of the WebDriver class.
For example:
```
from selenium import webdriver
driver = webdriver.Chrome()
element = driver.find_element_by_id("id_value")
```
In this code, we create an instance of the WebDriver class using the Chrome driver, and then find the element with the ID "id_value" using the "find_element_by_id" method on the driver instance. The resulting element object can then be used to interact with the web page.
阅读全文