Ejemplo n.º 1
0
    def test_register_code_right(self):
        username = util.get_random_str()
        email = username + "@qq.com"
        pwd = "123456"
        confirm_pwd = "123456"
        captcha = ""
        expected = "注册成功,点击确认进行登录。"

        self.driver.find_element_by_name("username").clear()
        self.driver.find_element_by_name("username").send_keys(username)
        self.driver.find_element_by_name("email").clear()
        self.driver.find_element_by_name("email").send_keys(email)
        self.driver.find_element_by_name("pwd").clear()
        self.driver.find_element_by_name("pwd").send_keys(pwd)
        self.driver.find_element_by_name("confirmPwd").clear()
        self.driver.find_element_by_name("confirmPwd").send_keys(confirm_pwd)
        captcha = util.get_code(self.driver, "captcha")
        self.driver.find_element_by_name("captcha").clear()
        self.driver.find_element_by_name("captcha").send_keys(captcha)
        self.driver.find_element_by_class_name("btn").click()

        WebDriverWait(self.driver, 5).until(EC.alert_is_present())
        alert = self.driver.switch_to.alert

        self.assertEqual(alert.text, expected)
        alert.accept()

        sleep(2)
Ejemplo n.º 2
0
    def test_register_code_error(self, username, email, pwd, confirm_pwd,
                                 captcha, expected):
        self.driver.find_element_by_name("username").clear()
        self.driver.find_element_by_name("username").send_keys(username)

        self.driver.find_element_by_name("email").clear()
        self.driver.find_element_by_name("email").send_keys(email)

        self.driver.find_element_by_name("pwd").clear()
        self.driver.find_element_by_name("pwd").send_keys(pwd)

        self.driver.find_element_by_name("confirmPwd").clear()
        self.driver.find_element_by_name("confirmPwd").send_keys(confirm_pwd)

        if captcha != '666':
            captcha = util.get_code(self.driver, "captcha")
        self.driver.find_element_by_name("captcha").clear()
        self.driver.find_element_by_name("captcha").send_keys(captcha)

        self.driver.find_element_by_class_name("btn").click()

        WebDriverWait(self.driver, 5).until(EC.alert_is_present())
        alert = self.driver.switch_to.alert

        assert alert.text == expected
        alert.accept()

        sleep(2)
Ejemplo n.º 3
0
    def test_register_code_error(self, username, email, pwd, confirm_pwd,
                                 captcha, expected):
        self.register_page.input_username(username)
        self.register_page.input_email(email)
        self.register_page.input_pwd(pwd)
        self.register_page.input_confirm_pwd(confirm_pwd)

        if captcha != '666':
            captcha = util.get_code(self.driver, "captcha")
        self.register_page.input_captcha(captcha)

        self.register_page.click_register_btn()

        WebDriverWait(self.driver, 5).until(EC.alert_is_present())
        alert = self.driver.switch_to.alert

        assert alert.text == expected
        alert.accept()

        sleep(2)
Ejemplo n.º 4
0
    def test_admin_login_right(self):
        username = "******"
        pwd = "chen"
        captcha = ""
        expected = "JPress后台"

        self.driver.find_element_by_name("user").clear()
        self.driver.find_element_by_name("user").send_keys(username)
        self.driver.find_element_by_name("pwd").clear()
        self.driver.find_element_by_name("pwd").send_keys(pwd)
        self.driver.find_element_by_name("captcha").clear()
        captcha = util.get_code(self.driver, "captchaImg")
        self.driver.find_element_by_name("captcha").send_keys(captcha)
        self.driver.find_element_by_class_name("btn").click()

        WebDriverWait(self.driver, 5).until(EC.title_is(expected))

        assert self.driver.title == expected

        sleep(2)