Viktor
Viktor

Reputation: 1046

Enter data into input field not working with selenium

I'm making basic script for sing-in into Instagram. I faced with this error

enter image description here

Code:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

browser = webdriver.Firefox()
browser.get('https://www.instagram.com/accounts/login/')

username = browser.find_element_by_name("username").send_keys('login')

Upvotes: 1

Views: 229

Answers (2)

Viktor
Viktor

Reputation: 722

Try to add

time.sleep(5)

before

username = browser.find_element_by_name("username").send_keys('login')

Might be page not fully loaded

Upvotes: 1

Gyrotank
Gyrotank

Reputation: 153

The error reads 'Window not found. The browser window may have been closed'. It happened in line browser.find_element_by_tag_name("body"). The Instagram login page has two such elements, and you need only one of them. You should make the query more specific, for instance by making it return only the first element with the tag.

Upvotes: 0

Related Questions