Reputation: 44385
I have created the following simple selenium test in order to start a browser, navigate to the google
main page and to insert some text in the search box:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser = webdriver.Firefox()
browser.get('http://www.google.com')
elem = browser.find_element_by_xpath('//input') # Find the search box
elem.send_keys('do a test search' + Keys.RETURN)
However, I get the following error in the send_keys
line:
selenium.common.exceptions.ElementNotInteractableException: Message: Element is not visible
Maybe this is a bad way to select the prominent input box on the google page? How to do it better?
(Remark: This is just supposed to be a simple setup to get selenium going. The system under test will be a different webpage, but I just want to make sure it works in this simple case...)
Upvotes: 0
Views: 137
Reputation: 52685
There are couple of hidden input
elements located before search input field.
browser.find_element_by_xpath('//input')
means return FIRST "input" node in DOM. That's why your elem
is actually hidden node and not interactable.
Try below instead
elem = browser.find_element_by_name("q")
Upvotes: 1