I am creating a Selenium bot in Python. The driver is supposed to open instagram.com and fill in the login form using the users credentials as an input. There is an error:
# FIRST I OPEN INSTAGRAM LIKE THIS
self.driver.get("https://www.instagram.com/")
# THEN A POP-UP APPEARS, AND I CLOSE IT BY CLICKING IN THE ACCEPT BUTTON,
# IT SEEMS LIKE IT IS NOT AN IFRAME SO NO FRAME SWITCHES ARE NEEDED
cooki = self.driver.find_element_by_xpath('/html/body/div[2]/div/div/div/div[2]/button[1]')
cooki.click()
# NOW I TRY TO FIND THE USERNAME FORM TO WRITE IN AN INPUT
usbar = self.driver.find_element_by_xpath('//*[@id="loginForm"]/div/div[1]') # ERROR HERE
usbar.send_keys(input('Username: '))
The error says:
NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="loginForm"]/div/div[1]"}
It cannot find the Username form to write in it. I believe there are no iframes in the way, I don't know if there is any other issue preventing the driver to find it. I am fairly new so I can't upload an image of the html of the page yet, that's why I include the line that opens the page. Can anyone come up with a foolproof solution?