0
import webbrowser
from selenium import webdriver

browser = webdriver.Chrome()
browser.maximize_window()
browser.get('https://www.suntrust.com/')
browser.implicitly_wait(15)
elem = browser.find_element_by_css_selector('input#sign-on-3A69E29D-79E0-
                                           403E-9352-5261239ADD89-user')
elem.click().send_keys('your-username')

element not visible exception error message:

enter image description here

I'm trying to sign into the login/password field automatically, but I keep getting this error message.

I have tried various "find_element_by" locators, but this one was recommended, so I don't think the css selector is the problem. What am I doing wrong?

1
  • try: elem.send_keys('your_username') Commented Jul 11, 2017 at 19:51

2 Answers 2

1

It happens usually because the dom wouldn't have loaded and the Selenium script tries to find that element .. Make sure this element is not inside an Iframe . Use the selenium explicit wait until the element loads and then perform action on that button . You have to do something like this in python . The below code is just creating a wait object and then waiting for the element to load and perform next step

from selenium.webdriver.support.ui import WebDriverWait


    myElem = WebDriverWait(browser, delay).until(EC.presence_of_element_located((By.ID, 'IdOfMyElement')))
    print "Page is ready!"
except TimeoutException:
    print "Loading took too much time!"
Sign up to request clarification or add additional context in comments.

Comments

0

Here is the Answer to your Question:

The css_selector you constructed was not unique and was matching to 2 elements on the HTML DOM. The first match was invisible while the second match was our expected element. Selenium was trying to click the first element. Hence the error. Here is your own code with the modified css_selector which works well at my end:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
browser = webdriver.Chrome(chrome_options=options, executable_path="C:\\Utility\\BrowserDrivers\\chromedriver.exe")
browser.get('https://www.suntrust.com/')
browser.implicitly_wait(15)
elem = browser.find_element_by_css_selector('section[role="main"] input[id="sign-on-3A69E29D-79E0-403E-9352-5261239ADD89-user"]')
elem.send_keys('your-username')

Let me know if this Answers your Question.

3 Comments

Didn't work for me in particular, but my question was answered elsewhere. Thanks for the feedback.
@Newbbit Can you please check my updated Answer? Its is working at my end. Thanks
Thanks :) I am just a learner like you and both the Answers are mine. Thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.