Reputation: 303
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!
Upvotes: 0
Views: 327
Reputation: 62
Instead of explicit localization of password element, it is often more practical something like this:
username.send_keys('bob' + Keys.TAB + 'pop' + Keys.ENTER)
Upvotes: 1