[Solved] AttributeError: ‘WebDriver‘ object has no attribute ‘find_element_by_id‘

1. Question:

When learning the selenium part of the crawler, AttributeError appears: ‘WebDriver’ object has no attribute ‘find_ element_ by_ Id ‘problem.

2. Reasons:

Because of version iteration, find_element_by_id method is not supported in the new version of selenium.

3. Solution:

Modify button = browser.find_element_by_id(‘su’) to the following codes:

button = browser.find_element(By.ID,'su')

Add the following code at the front of the code page,

from selenium.webdriver.common.by import By

Read More: