예제 #1
0
class TestLogin():
    @pytest.fixture(scope='function', autouse=True)
    def func_scope(self):

        # 前置:打开浏览器,登录网页
        self.driver = InitializeDriver.CustomDriver
        self.driver.get(cd.web_login_url)
        self.lp = LoginPage(self.driver)
        yield

        # 刷新一下当前页面
        self.driver.refresh()

    # 正常用例
    @pytest.mark.parametrize('data', ld.success_data)
    def test_login_2_success(self, data):
        logging.info("*********登录用例:正常场景-登录成功*********")
        # 步骤:登录页面-登录操作
        self.lp.login(data["user"], data["pwd"])
        time.sleep(3)
        # 断言:首页-LOGO这个元素存在
        assert HomePage(self.driver).check_login_ele_exists()

    # 异常用例
    @pytest.mark.parametrize('data', ld.wrong_datas)
    def test_login_1_error(self, data):
        time.sleep(2)
        logging.info("*********登录用例:异常场景-登录失败*********")
        self.lp.login(data["user"], data["pwd"])
        time.sleep(2)
        # 断言:判断提示信息是否一致
        assert data["check"] == LoginPage(self.driver).get_errorMsg()
예제 #2
0
    def func_scope(self):

        # 前置:打开浏览器,登录网页
        self.driver = InitializeDriver.CustomDriver
        self.driver.get(cd.web_login_url)
        self.lp = LoginPage(self.driver)
        yield

        # 刷新一下当前页面
        self.driver.refresh()
예제 #3
0
 def test_login_1_error(self, data):
     time.sleep(2)
     logging.info("*********登录用例:异常场景-登录失败*********")
     self.lp.login(data["user"], data["pwd"])
     time.sleep(2)
     # 断言:判断提示信息是否一致
     self.assertEqual(data["check"], LoginPage(self.driver).get_errorMsg())
예제 #4
0
 def setUpClass(cls):
     # 前置:打开浏览器,登录网页
     cls.driver = webdriver.Chrome()
     cls.driver.maximize_window()
     cls.driver.get(cd.web_login_url)
     cls.lp = LoginPage(cls.driver)
예제 #5
0
 def setUpClass(cls):
     # 前置:打开浏览器,登录网页
     cls.driver = InitializeDriver.get_headers_driver()
     cls.driver.get(cd.web_login_url)
     cls.lp = LoginPage(cls.driver)