Auto WP login with selenium

From the Automate the Boring Stuff with Python book:

from selenium import webdriver
browser = webdriver.Chrome()
browser.get('https://blog.dukic.co.nz/wp-login.php')
usernameBox = browser.find_element_by_id('user_login')
usernameBox.send_keys('srdan')
passwordBox = browser.find_element_by_id('user_pass')
passwordBox.send_keys('PASSWORD HERE')
passwordBox.submit()

Needed to make sure to have “chromedriver” installed from brew on OS X. Tried getting it working with Firefox driver (geckodriver) but hit a bunch of issues with not being able to find binaries when trying with Firefox Nightly edition.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.