baseurl = 'http://www.mywebsite.com/login.php'
username = 'admin'
password = 'admin'
xpaths = {'usernameTxtBox': "//input[@name='username']", 'passwordTxtBox':
    "//input[@name='password']", 'submitButton': "//input[@name='login']"}
mydriver = webdriver.Firefox()
mydriver.get(baseurl)
mydriver.maximize_window()
mydriver.find_element_by_xpath(xpaths['usernameTxtBox']).clear()
mydriver.find_element_by_xpath(xpaths['usernameTxtBox']).send_keys(username)
mydriver.find_element_by_xpath(xpaths['passwordTxtBox']).clear()
mydriver.find_element_by_xpath(xpaths['passwordTxtBox']).send_keys(password)
mydriver.find_element_by_xpath(xpaths['submitButton']).click()
How to use Selenium with Python?