I am trying to make a web scraper for my school website. This will enter my username and password and click the sign in button. It works sometimes, but otherwise it will give error messages. There are two pages in my school website, the login page and the main page. I only entered the main page's link so idk if that's the problem. here's the code:
from selenium import webdriver
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("anonymous")
search1 = driver.find_element_by_id('username')
search1.send_keys('*********')
search2 = driver.find_element_by_id('pwd')
search2.send_keys('******')
submitbutton = driver.find_element_by_xpath('anonymous_x_path')
submitbutton.click()
the errors are:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="username"]"}
raise exception_class(message, screen, stacktrace)
self.error_handler.check_response(response)
return self.execute(Command.FIND_ELEMENT, {
return self.find_element(by=By.ID, value=id_)
search1 = driver.find_element_by_id('username')