0

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!

ajbentley
  • 193
  • 1
  • 10

1 Answers1

1

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

username.send_keys('bob' + Keys.TAB + 'pop' + Keys.ENTER) 
RF1991
  • 2,037
  • 4
  • 8
  • 17
mmichalik
  • 64
  • 1
  • 6
  • I had a feeling keys.tab would be part of it but couldn't get it to work correctly. This did the trick. Thanks so much! – ajbentley Jul 31 '17 at 03:59