1

I am trying to web scrape my school's website. Currently I am stuck at the log-in process. Basically here is what logging in would entail:

  1. Click log-in in upper-right corner of website
  2. A pop-up will show up in the center of the screen asking your log in credentials
  3. Input credentials
  4. Press log in.

Here is what my code is looking right now:

from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from time import sleep 

driver = webdriver.Firefox(executable_path = 'driver path')

driver.get ('website.url')
driver.find_element_by_class_name('btn-login').click()  #clicks login button
sleep(50) 
driver.find_element_by_name('username').send_keys('myusername') #inputs username
driver.find_element_by_name ('password').send_keys('mypassword') #inputs password
driver.find_element_by_name('password').send_keys(Keys.ENTER) #clicks enter

I have managed to click the log in button, but I am having trouble inputting the username and password, I get the following error as I get to the inputting part.

selenium.common.exceptions.ElementNotInteractableException: Message: Element <input id="username" name="username" type="text"> is not reachable by keyboard

I googled a bit and thought that it might be the website loading the pop-up faster than my code could read, so I used sleep(), but even with arbitrarily large values where the website should have had enough time the same error persists. Any idea what could have been happening in the background and what steps I should take?

Edit

Here are the elements for the username and password input boxes respectively

<input autofocus="" type="text" name="username" placeholder="Username" style="width:97%;font-size:16px;height:30px;">
<input type="password" name="password" placeholder="Password" style="width:97%;font-size:16px;height:30px;">

I tried to debug by using the following code:

if driver.find_element_by_name('username'):
    print('element found')

And it does indeed find the element, so I do not think switching frames is the problem. The element is really not reachable by keyboard (which should not be the case). Any thoughts on why this is and how to fix it?

0 Answers0