Python+Selenium Error: AttributeError: ‘WebDriver‘ NameError: name ‘By‘ is not defined

python 3.10.1

selenium 4.4.3

Old version Package:

from selenium import webdriver

New version Package:

from selenium import webdriver
from selenium.webdriver.common.by import By

You need to import one more, otherwise the ‘By’ will report an error

Positioning statement

drive.find_element(By.NAME,"username").send_keys("astudy")

Read More: