0

I am trying to use selenium to log into this website: but it says the password and login are not visible. I looked around and saw that some people said to wait, but waiting does not seem to help. Here is my code:

    # importing libraries
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import re, time, csv


driver = webdriver.Firefox()

driver.get("https://platform.openquake.org/account/login/")
driver.switch_to
driver.maximize_window
time.sleep(10)

username = driver.find_element_by_xpath("//input[@name='username']")
username.send_keys("hi there")

Error message is :

ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Corncobpipe
  • 51
  • 1
  • 7
  • 1
    This might be helpful: http://stackoverflow.com/questions/27927964/selenium-element-not-visible-exception – mark s. May 12 '16 at 16:38
  • Hmm its a bit confusing on how to do it for my particular circumstance. I was able to solve use tab to get around it. – Corncobpipe May 12 '16 at 17:21

2 Answers2

1

Modify your xpath:

username = driver.find_element_by_xpath("//div[@class='controls']/input[@id='id_username']")
Tanu
  • 1,503
  • 12
  • 21
1

Your XPATH actually matches two elements. The non-plural driver methods (find_element_by_XXX) return the first element they find a match for, which in this case is not the one you want.

A good debugging tool for situations like this is to use the plural forms (find_elements_by_XXX) and then see how many elements matched.

In this case, you should do what Tanu suggested and use a more restrictive XPATH:

username = driver.find_element_by_xpath("//div[@class='controls']/input[@id='id_username']")
password = driver.find_element_by_xpath("//div[@class='controls']/input[@id='id_password']")
Levi Noecker
  • 3,142
  • 1
  • 15
  • 30