Unverified Commit aebe969f authored by Johannes Tomren Røsvik's avatar Johannes Tomren Røsvik
Browse files

Generalise input functions for test_signup

parent 994b56cf
Pipeline #76957 passed with stage
in 1 minute and 7 seconds
......@@ -28,8 +28,15 @@ class AgreelanceSignUp(unittest.TestCase):
else:
self.driver = webdriver.Chrome("./bin/chromedriver")
# Input random valid info in form
def test_fill_form_valid(self):
def test_nominal(self):
driver = self.driver
values = self.getNominalValues()
formstate = self.fill_form(values)
self.assertTrue(formstate)
def fill_form(self, values):
driver = self.driver
driver.get(url)
......@@ -52,43 +59,58 @@ class AgreelanceSignUp(unittest.TestCase):
recaptcha = driver.find_element_by_class_name("g-recaptcha")
submit = driver.find_element_by_xpath("/html/body/div[1]/form/button")
username.send_keys(self.rString(30))
firstname.send_keys(self.rString(30))
lastname.send_keys(self.rString(30))
categories.select_by_index(0)
company.send_keys(self.rString(30))
email_ = self.rString(10) + "@" + self.rString(10) + ".com"
email.send_keys(email_)
email_confirmation.send_keys(email_)
password_ = self.rString(30)
password.send_keys(password_)
password_confirmation.send_keys(password_)
phone_number.send_keys(self.rDigits(8))
country.send_keys(self.rString(30))
state.send_keys(self.rString(30))
city.send_keys(self.rString(30))
postal_code.send_keys(self.rDigits(4))
street_address.send_keys(self.rString(30))
recaptcha.click()
username.send_keys(values["username"])
firstname.send_keys(values["firstname"])
lastname.send_keys(values["lastname"])
categories.select_by_index(values["categories"])
company.send_keys(values["company"])
email.send_keys(values["email"])
email_confirmation.send_keys(values["email_confirmation"])
password.send_keys(values["password"])
password_confirmation.send_keys(values["password_confirmation"])
phone_number.send_keys(values["phone_number"])
country.send_keys(values["country"])
state.send_keys(values["state"])
city.send_keys(values["city"])
postal_code.send_keys(values["postal_code"])
street_address.send_keys(values["street_address"])
# recaptcha.click()
submit.click()
timeout = 5
timeout = 1
try:
element_present = EC.presence_of_element_located((By.CLASS_NAME, 'alert'))
WebDriverWait(driver, timeout).until(element_present)
alert = driver.find_element_by_class_name("alert")
return "Your account has been created" in alert.text
except TimeoutException:
print("Timed out waiting for page to load")
alert = driver.find_element_by_class_name("alert")
self.assertTrue("Your account has been created and is awaiting verification" in alert.text)
return False
def getNominalValues(self):
email_ = self.rString(10) + "@" + self.rString(10) + ".com"
password_ = self.rString(30)
values = {
"username": self.rString(30),
"firstname": self.rString(30),
"lastname": self.rString(30),
"categories": 0,
"company": self.rString(30),
"email": email_,
"email_confirmation": email_,
"password": password_,
"password_confirmation": password_,
"phone_number": self.rDigits(8),
"country": self.rString(30),
"state": self.rString(30),
"city": self.rString(30),
"postal_code": self.rDigits(4),
"street_address": self.rString(30)
}
return values
def tearDown(self):
self.driver.close()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment