Selenium fill in user name/pwd, only filling one field

Question:

I’m trying to do some web scraping and need to have selenium fill in login credentials, name and password.

I followed the directions here Fill username and password using selenium in python

Here’s my code:

username = driver.find_element_by_class_name('login-username')
username.send_keys('bob')

password = driver.find_element_by_class_name('login-password')
password.send_keys('pop')

driver.find_element_by_id('login_checkbox').click()
driver.find_element_by_class_name('ok').click()

This works to get to the username but it won’t move forward to the password. I end up with bobpop in the username field and, naturally, I can’t move forward.

Please help me figure out how to make this happen!

Asked By: ajbentley

||

Answers:

Instead of explicit localization of password element, it is often more practical something like this:

username.send_keys('bob' + Keys.TAB + 'pop' + Keys.ENTER) 
Answered By: mmichalik
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.