I am attempting to build a web scraper in Selenium. The first thing I want the script to do is to log in with my credentials into a database. Thus, I attempted to use find_element in order locate the user id/password entry fields.
However, when I used find_element, I was thrown the following error: "By" is not defined Pylance (reportUndefinedVariable).
I've read the Selenium 4 documentation at selenium.dev, but I'm not sure what exactly has gone wrong here.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.edge.service import Service as EdgeService
from selenium.webdriver.firefox.service import Service as FirefoxService
from selenium.webdriver.ie.service import Service as IEService
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.firefox import GeckoDriverManager
from webdriver_manager.microsoft import EdgeChromiumDriverManager
from webdriver_manager.microsoft import IEDriverManager
def test_driver_manager_chrome():
service = ChromeService(executable_path=ChromeDriverManager().install())
driver = webdriver.Chrome(service=service)
driver.quit()
#open the browser
driver = webdriver.Chrome()
driver.implicitly_wait(30)
driver.maximize_window
#navigate to the website
driver.get("URL")
#log in
userID = driver.find_element(By.ID, "_58_login")