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
2
  • 1
    This might be helpful: stackoverflow.com/questions/27927964/… Commented May 12, 2016 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. Commented May 12, 2016 at 17:21

2 Answers 2

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']")
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! I'll make sure to use this!
1

Modify your xpath:

username = driver.find_element_by_xpath("//div[@class='controls']/input[@id='id_username']")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.