Beispiel #1
0
class TestLogin(object):
    """登陆测试类"""
    @pytest.fixture(autouse=True)
    def befort_fun(self):
        """前置操作"""
        self.driver = ini_driver()  # 获取驱动对象
        self.page_factory = PageFactory(self.driver)
        yield
        time.sleep(2)
        self.driver.quit()

    @pytest.mark.parametrize("num,pwd,expect", build_login_data())
    def test_login(self, num, pwd, expect):
        """测试登陆方法"""
        #
        # self.page_factory.index_page().click_mine()  # 点击我的
        # self.page_factory.mine_page().click_login_ret()  # 点击登录/注册
        # self.page_factory.login_page().input_phone_num("13580084109")  # 输入账号
        # self.page_factory.login_page().input_pwd("qiya77a369")  # 输入密码
        # self.page_factory.login_page().click_login_but()  # 点击登录
        # self.page_factory.login_page().click_alert_but()  # 点击弹出确认按钮

        self.page_factory.index_page().click_mine()  # 点击我的
        self.page_factory.mine_page().click_login_ret()  # 点击登录/注册
        self.page_factory.login_page().logint_func(num, pwd)  # 登陆操作
        username_text = self.page_factory.mine_page().get_usernmae_text(
        )  # 用户名标题
        assert username_text in expect  # 判断断言结果
Beispiel #2
0
class TestLogin(object):
    """登录测试类"""
    @pytest.fixture(autouse=True)
    def before_func(self):
        """前置操作"""
        self.driver = init_driver()  # 获取驱动对象
        self.page_factory = PageFactory(self.driver)

        yield
        time.sleep(2)
        self.driver.quit()

    def test_login(self):
        """登录测试方法"""
        # self.page_factory.index_page().click_mine()  # 点击我的
        # self.page_factory.mine_page().click_login_reg()  # 点击登录注册
        # self.page_factory.login_page().input_phone_num('15570925914')  # 输入手机号码
        # self.page_factory.login_page().input_pwd('qwer123456789')  # 输入密码
        # self.page_factory.login_page().click_login_btn()  # 点击登录按钮
        # self.page_factory.login_page().click_alert_btn()  # 点击弹窗按钮

        self.page_factory.index_page().click_mine()  # 点击我的
        self.page_factory.mine_page().click_login_reg()  # 点击登录注册
        self.page_factory.login_page().login_func('15570925914',
                                                  'qwer123456789')  # 登录操作
Beispiel #3
0
class TestLogin(object):
    @pytest.fixture(autouse=True)
    def before_func(self):
        self.driver = init_driver()
        self.page_factory = PageFactory(self.driver)
        yield
        time.sleep(1)
        self.driver.quit()

    def test_login(self):
        self.page_factory.index_page().clicl_mine()
        self.page_factory.mine_page().click_login_reg()
        self.page_factory.login_page().input_phone_num(12345678901)
        self.page_factory.login_page().input_pwd(123456)
        self.page_factory.login_page().click_login_btn()
class TestLogin(object):
    """登录测试类"""
    @pytest.fixture(autouse=True)
    def before_func(self):
        self.driver = get_driver()  # 获取驱动对象
        self.page_factory = PageFactory(self.driver)  # 实例化统一入口类
        yield  # 结束工作
        self.driver.quit()

    def test_login(self):
        """登录测试方法"""
        # 成功登录
        # self.page_factory.index_page().click_mine()  # 点击我的
        # self.page_factory.mine_page().click_login()  # 点击登录/注册
        # self.page_factory.login_page().login_func('13157523435', 'lm123456')  # 登录
        # self.page_factory.login_page().click_confirm_btn() # 点击登录提示确定按钮
        # # 断言
        # username_text = self.page_factory.mine_page().get_username_text()
        # assert '3435' in username_text

        # 未注册
        self.page_factory.index_page().click_mine()  # 点击我的
        self.page_factory.mine_page().click_login()  # 点击登录/注册
        self.page_factory.login_page().login_func('13800001111',
                                                  'lm123456')  # 登录

        try:
            # 断言
            toast_msg = self.page_factory.login_page().get_login_toast(
                '账号还未注册')
            assert '账号还未注册' in toast_msg

        except AssertionError as e:  # AssertionError: 为断言失败异常类型

            # 给 allure 报告添加截图(断言失败时进行截图操作)
            self.driver.get_screenshot_as_file('./screenshot/info.png')
            # rb: 以二进制方式读取
            with open('./screenshot/info.png', 'rb') as f:
                # allure.MASTER_HELPER.attach('文件名称', 文件内容, 文件类型)
                allure.MASTER_HELPER.attach(
                    'my_info', f.read(), allure.MASTER_HELPER.attach_type.PNG)

            raise e  # 当截图操作完成后, 应该还原测试用例的真实结果, 因此需要再主动抛出异常
Beispiel #5
0
class TestLogin(object):
    """搜索测试类"""
    @pytest.fixture(autouse=True)
    def before_func(self):
        DriverUtil.get_driver()  # 获取驱动对象
        self.factory = PageFactory()

        yield  # 结束操作
        time.sleep(3)
        DriverUtil.quit_driver()  # 退出驱动对象

    def test_login(self):
        self.factory.index_page().click_mine()
        self.factory.mine_page().click_login()
        self.factory.login_page().login('13157523435', 'lm123456')
        self.factory.login_page().click_confirm()
        # 断言
        username_text = self.factory.mine_page().get_username_text()
        assert '3435' in username_text
class TestLogin(object):
    """登录测试类"""
    def setup_class(self):
        self.driver = init_driver()  # 驱动对象获取
        self.page_factory = PageFactory(self.driver)  # 工厂类实例化

    def teardown_class(self):
        self.driver.quit()  # 退出驱动对象

    def test_login(self):
        """测试登录方法"""
        self.page_factory.home_page().click_mine()  # 点击我的
        self.page_factory.mine_page().click_login()  # 点击登录注册
        self.page_factory.login_page().input_username("13058070271")  # 输入账号
        self.page_factory.login_page().input_password("zm4567890")  # 输入密码
        self.page_factory.login_page().click_login_btn()  # 点击登录
        self.page_factory.login_page().click_con_btn()  # 点击确认
        nick_name = self.page_factory.login_page().get_nick_name()  # 获取昵称
        print("昵称是:", nick_name)
        # 断言判断结果
        assert 5372 in nick_name
Beispiel #7
0
class TestLogin(object):
    @pytest.fixture(autouse=True)
    def before(self):
        self.driver = init_driver()
        self.page_factory = PageFactory(self.driver)

        yield
        time.sleep(2)
        self.driver.quit()

    @pytest.mark.parametrize('type,username,pwd,expect', read_data())
    def test_login(self, type, username, pwd, expect):
        if type:

            # 点击我的
            self.page_factory.first_page().click_mine_btn()
            # 点击登录按钮
            self.page_factory.mine_page().click_log_reg_btn()
            # 输入用户名
            self.page_factory.login_page().input_username(username)
            #输入密码
            self.page_factory.login_page().input_password(pwd)
            #点击登录
            self.page_factory.login_page().click_login_btn()
            #点击弹出框
            self.page_factory.login_page().click_alter_btn()

            # #正向
            # self.page_factory.login_page().login_func(username,pwd)
            # #获取用户名
            # username_text = self.page_factory.mine_page().get_username_text()
            # # print(username_text)
            # #断言
            # assert username_text in expect
        else:
            #反向
            # 点击我的
            self.page_factory.first_page().click_mine_btn()
            # 点击登录按钮
            self.page_factory.mine_page().click_log_reg_btn()
            # 输入用户名
            self.page_factory.login_page().input_username(username)
            # #输入密码
            self.page_factory.login_page().input_password(pwd)
            # #点击登录
            self.page_factory.login_page().click_login_btn()

            # 截图
            image_name = BASE_DIR + '/image/info_{}.png'.format(
                time.strftime('%Y%m%d_%H%M%S'))
            self.driver.get_screenshot_as_file(image_name)
            # 注意: 需要打开生成截图文件, 再写入 allure 报告
            with open(image_name, 'rb') as f:
                # 注意: 写入语法必须保证在 with open() 方法的作用域范围内
                allure.MASTER_HELPER.attach(
                    'info', f.read(), allure.MASTER_HELPER.attach_type.PNG)

            # #获取弹出信息
            toast_msg = self.page_factory.login_page().get_toast_message(
                expect)
            print(toast_msg)
            #断言
            assert expect in toast_msg