Reputation: 1913
I am going through a process of registering and logging in for a list of users.
I am using the same username and password to make things simple.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import re
for address in geolocations:
# register
browser.get("http://127.0.0.1:8000/register")
username = browser.find_element_by_id("id_username")
print("username is being set as " + re.sub(' ', '', address))
password = browser.find_element_by_id("id_password")
print("password is being set as " + re.sub(' ', '', address))
location = browser.find_element_by_id("location")
submit = browser.find_element_by_id("register")
username.clear()
password.clear()
location.clear()
username.send_keys(re.sub(' ', '', address))
password.send_keys(re.sub(' ', '', address))
location.send_keys(address)
location.send_keys(Keys.RETURN)
submit.click()
browser.implicitly_wait(1)
# login
browser.get("http://127.0.0.1:8000/login")
username = browser.find_element_by_id("username")
password = browser.find_element_by_id("password")
username.clear()
password.clear()
password.send_keys(re.sub(' ', '', address)) # addresses have spaces
print("password is being set as: " + re.sub(' ', '', address))
browser.implicitly_wait(2)
submit = browser.find_element_by_id("submit")
submit.click()
browser.implicitly_wait(2)
browser.quit()
Even though the same string is being used for registering and logging in, the login authentication is not working. But the same username/password combos work when I register/login manually.
Can anyone tell me what's causing this?
Upvotes: 0
Views: 112
Reputation: 308999
In the login section of your test, it looks like you have forgotten to call username.send_keys()
.
Upvotes: 2