Example #1
0
    def test_new_registration(self):
        registration_page = RegistrationPage(self.wd, self)
        registration_page.go_to()
        username_available = False
        index = 1

        while not username_available:
            test_username = "******" + ` index `
            test_password = "******"
            self.wd.find_css('#id_username').clear()
            self.wd.find_css('#id_username').send_keys(test_username)
            self.wd.find_css('#id_email').clear()
            self.wd.find_css('#id_email').send_keys(test_username +
                                                    "@example.com")
            self.wd.find_css("#id_password1").clear()
            self.wd.find_css("#id_password1").send_keys(test_password)
            self.wd.find_css("#id_password2").clear()
            self.wd.find_css("#id_password2").send_keys(test_password)
            self.wd.find_css("#id_full_name").send_keys('')
            action = ActionChains(self.wd)
            action.send_keys(Keys.TAB).send_keys(Keys.RETURN).perform()

            time.sleep(1)
            elems = self.wd.find_elements_by_xpath(
                "//*[contains(text(), 'A user with that username already exists.')]"
            )
            if len(elems) == 0:
                username_available = True
                Credentials().set_test_username(test_username)
                Credentials().set_test_password(test_password)
                Credentials().set_test_email(test_username + "@example.com")
                assert self.wd.wait_for_css('.btn-user')
            else:
                index = index + 1
Example #2
0
 def user_login(self):
     self.open("/account/login/")
     self.wd.find_css('#id_login').send_keys(
         Credentials().get_test_username())
     self.wd.find_css("#id_password").send_keys(
         Credentials().get_test_password())
     self.wd.find_element_by_xpath('//button[@name="sign-in"]').click()
Example #3
0
 def test_password_reset(self):
     self.user_login()
     self.wd.wait_for_css('.btn-user')
     self.open("/account/password/reset/")
     self.wd.find_css('#id_email').send_keys(Credentials.get_test_email())
     self.wd.find_element_by_xpath(
         '//input[@value="Reset password"]').click()
     text = self.wd.find_element_by_xpath("//h1").text
     assert text == "Password reset"
Example #4
0
    def test_registration_attempt_already_taken_email(self):
        registration_page = RegistrationPage(self.wd, self)
        registration_page.go_to()

        self.wd.find_css('#id_username').send_keys("cadasta-test-user")
        self.wd.find_css('#id_email').send_keys(Credentials().get_test_email())
        self.wd.find_css("#id_password1").send_keys('XYZ#qwerty')
        self.wd.find_css("#id_password2").send_keys('XYZ#qwerty')
        self.wd.find_css("#id_full_name").send_keys('')
        action = ActionChains(self.wd)
        action.send_keys(Keys.TAB).send_keys(Keys.RETURN).perform()

        assert self.wd.wait_for_xpath(
            "//*[contains(text(), 'Another user with this email already exists')]"
        )
Example #5
0
 def tearDown(self):
     self.restore_username(Credentials.get_test_username())
     self.wd.quit()
 def tearDown(self):
     self.restore_email(Credentials.get_test_email())
     self.wd.quit()