I have multiple sign up pages that I am currently testing. Each of the form have seprate fields. However, some share common fields(as you can see from signup page.py).
This is what I have so far(I am using Page Object method), I would like to know how I can improve my code to make it more robust.
Here is the signUp page.py:
class signupPage(Page):
def __init__(self, driver):
super(signupPage, self).__init__(driver)
def SignupPage1139_CompanyOne(self):
self.driver.get("https://abc.com/s_csignup.jsp?token=XVtQHUUGYFFaRhNaXxJaQVBRZEl2EnBo")
self.driver.find_element_by_id("cname").clear()
self.driver.find_element_by_id("cname").send_keys("QA EXTERNAL")
self.driver.find_element_by_id("cf_2727675").clear()
self.driver.find_element_by_id("cf_2727675").send_keys("Test")
self.driver.find_element_by_id("cf_2697953").clear()
self.driver.find_element_by_id("cf_2697953").send_keys("Test")
self.driver.find_element_by_id("sbbut").click()
self.assertEqual("Could not create organization, an organization with the entered criteria already exists.", self.close_alert_and_get_its_text())
def SignupPage1139_CompanyTwo(self):
self.driver.get("https://abc.com/s_csignup.jsp?token=XVtQHUUGYFFaRhNaXxJaQVBRZElzGnJt")
self.driver.find_element_by_id("cname").clear()
self.driver.find_element_by_id("cname").send_keys("QA EXTERNAL")
self.driver.find_element_by_id("city").clear()
self.driver.find_element_by_id("city").send_keys("Toronto")
Select(self.driver.find_element_by_id("state")).select_by_visible_text("Ontario")
self.driver.find_element_by_id("sbbut").click()
self.assertEqual("Cannot update using new scripts as there is already a matching company", self.close_alert_and_get_its_text())
def SignupPage1139_CompanyThree(self):
self.driver.get("https://abc.com/s_csignup.jsp?token=XVtQHUUGYFFcRhZdXxJaQVBRZEl9HnRr")
self.driver.find_element_by_id("cname").clear()
self.driver.find_element_by_id("cname").send_keys("DO NOT DELETE - Pandora External")
self.driver.find_element_by_id("cf_2698238").clear()
self.driver.find_element_by_id("cf_2698238").send_keys("000000124")
self.driver.find_element_by_id("sbbut").click()
Here is my test.py:
class MatchingContactCompany(BaseTestCase, unittest.TestCase):
def setUp(self):
super(MatchingContactCompany, self).setUp()
def test_MatchingCompany(self):
# form 1
signup.obj = signupPage(self.driver)
signup.obj.SignupPage1139_CompanyOne()
# form 2
signup.obj.SignupPage1139_CompanyTwo()
# form 3 create the account and verify if the account was created
signup.obj.SignupPage1139_CompanyThree()
def tearDown(self):
super(MatchingContactCompany, self).tearDown()
if __name__ == "__main__":
unittest.main()