예제 #1
0
class TestLogin:
    def setup(self):
        # 浏览器驱动对象获取
        self.driver = DriverUtil.get_driver()
        self.login_page = LoginPage(self.driver)
        self.index_page = IndexPage(self.driver)
        self.driver.get("http://192.168.2.133/")

    def teardown(self):
        # 浏览器驱动对象关闭
        time.sleep(3)
        DriverUtil.close_driver()

    @pytest.mark.parametrize("params", analyze("login_data"))
    def test_login(self, params):
        self.index_page.click_login_link()
        self.login_page.input_username(params["username"])
        self.login_page.input_password(params["password"])
        self.login_page.input_verify_code(params["code"])
        self.login_page.click_login_btn()
        logging.info("登录, 用户名为{}, 密码是{}, 验证码是{}".format(
            params["username"], params["password"], params["code"]))
        time.sleep(2)
        self.login_page.screen_shot("{}.png".format(
            self.login_page.get_error_msg()))
        assert params["msg"] == self.login_page.get_error_msg()
예제 #2
0
class TestLogin:
    def setup(self):
        self.driver = DriverUtils.get_driver()
        DriverUtils.set_switch(True)
        self.index_page = IndexPage(self.driver)
        self.login_page = LoginPage(self.driver)
        self.driver.get("http://localhost/")

    def teardown(self):
        time.sleep(3)
        DriverUtils.quit_driver()

    @pytest.mark.parametrize("params", analyze_data("login_data.json"))
    def test_login(self, params):
        self.index_page.click_login_link()
        logging.info("login with {}--{}--{}".format(params["username"],
                                                    params["password"],
                                                    params["code"]))
        self.login_page.input_username(params["username"])
        self.login_page.input_password(params["password"])
        self.login_page.input_verify_code(params["code"])
        self.login_page.click_login_btn()
        # 登录成功需要时间, 暂停几秒等页面跳转
        logging.info("wait 5s for page display")
        time.sleep(5)
        assert params["msg"] in self.driver.title
예제 #3
0
class TestLogin:
    def setup(self):
        self.driver = DriverUtil.get_driver()
        self.login_page = LoginPage(self.driver)
        self.index_page = IndexPage(self.driver)
        self.driver.get("http://localhost")

    def teardown(self):
        time.sleep(3)
        DriverUtil.quit_driver()

    @pytest.mark.parametrize("params", analyse("login_data.json"))
    def test_login(self, params):
        self.index_page.click_login_link()
        self.login_page.input_username(params["username"])
        self.login_page.input_password(params["password"])
        self.login_page.input_verify_code(params["code"])
        self.login_page.click_login_btn()
        time.sleep(3)
        logging.info("用户名: {}---密码: {}---验证码: {}---预期结果: {}".format(
            params["username"], params["password"], params["code"],
            params["msg"]))
        assert params["msg"] == self.login_page.get_msg()
예제 #4
0
class TestLogin:

    def setup(self):
        # 浏览器驱动对象获取
        self.driver = DriverUtil.get_driver()
        self.login_page = LoginPage(self.driver)
        self.index_page = IndexPage(self.driver)
        self.driver.get("http://192.168.2.133/")

    def teardown(self):
        # 浏览器驱动对象关闭
        time.sleep(3)
        DriverUtil.close_driver()

    @pytest.mark.parametrize("params", [{"username": "******", "password": "******", "code": "8888", "msg": "账号不存在!"},
                                        {"username": "******", "password": "******", "code": "8888", "msg": "密码错误!"}])
    def test_login(self, params):
        self.index_page.click_login_link()
        self.login_page.input_username(params["username"])
        self.login_page.input_password(params["password"])
        self.login_page.input_verify_code(params["code"])
        self.login_page.click_login_btn()
        time.sleep(2)
        assert params["msg"] == self.login_page.get_error_msg()