Esempio n. 1
0
class TestLogin:
    def setup(self):
        self.driver = init_driver()
        self.login_page = PageLogin(self.driver)

    # 测试步骤  函数的运行先后顺序
    @allure.step('我是测试步骤001')
    # 测试重要程度  #Severity:严重级别(BLOCKER,CRITICAL,NORMAL,MINOR,TRIVIAL)
    @pytest.allure.severity(pytest.allure.severity_level.CRITICAL)
    # 参数化
    @pytest.mark.parametrize("args", data_with_key("test_login"))
    def test_login(self, args):
        # self.login_page.click_mime()
        # self.login_page.click_login_getup()
        # self.login_page.send_text_username(13472435946)
        # self.login_page.send_text_password(123456)
        # self.login_page.click_login()
        # assert self.login_page.is_login(13472435946)
        username = args["username"]
        password = args["password"]
        toast = args["toast"]

        # 步骤说明
        # allure.attach('输入用户名', '13472435946')
        allure.attach('输入用户名' + username, '')
        # 输入手机号
        self.login_page.send_text_username(username)
        allure.attach('输入密码' + password, '')
        # 输入密码
        self.login_page.send_text_password(password)
        # 点击登录
        self.login_page.click_login()
        assert self.login_page.is_toast_exist(toast)
Esempio n. 2
0
class Test_Login():
    def setup(self):
        self.driver = Base_Init()  #实例化一个驱动
        self.login_driver = PageLogin(self.driver)  #将初始化的驱动传给page页面,也传给test页面

    #[("15602160302","123456"),("1234567899","123")]
    @pytest.mark.parametrize(("args"), data_with_key("test_login"))
    @allure.step(title="登录测试")
    def test_login(self, args):
        #1.输入用户名
        allure.attach('输入用户名', args["username"])
        self.login_driver.input_username(args["username"])
        #2.输入密码
        allure.attach('输入密码', args["password"])
        self.login_driver.input_password(args["password"])
        #3.点击确定
        allure.attach('点击登录按钮', '')
        self.login_driver.click_login()
        #4.判断是否登录成功
        result = self.login_driver.is_login("lq_1206085724_ybv")
        print(result)
        allure.attach('判断结果', str(result))
        #5.截图并上传至allure
        self.login_driver.screenshot(args["username"])
        allure.attach(
            "图片",
            open('./screen/' + args["username"] + '.png', 'rb').read(),
            allure.attach_type.PNG)
Esempio n. 3
0
class TestLogin:
    def setup(self):
        self.driver = init_driver()
        self.page_login = PageLogin(self.driver)  #页面类的构造函数

        #真机运行该app时,有这些弹窗问题。注意:安卓模拟器是没有弹窗问题的!
        #点击“交易猫app”首次启动时的“开启权限”弹窗
        self.page_login.click_tancuan((By.XPATH, "text,立即开启,1"))
        self.page_login.click_tancuan((By.XPATH, "text,始终允许,1"))
        self.page_login.click_tancuan((By.XPATH, "text,始终允许,1"))
        #点击“交易猫”app首次启动时的“广告弹窗”
        self.page_login.click_tancuan((By.ID, "com.jym.mall:id/iv_close"))

    def teardown(self):
        self.driver.quit()

    @allure.step(title="测试“登录”模块的测试脚本")
    @pytest.mark.parametrize("dict_data", data_with_key("test_login"))
    def test_login(self, dict_data):  #形参dict_data是字典类型
        username = dict_data["username"]
        password = dict_data["pwd"]
        toast = dict_data["toast"]
        screen = dict_data["screen"]

        #步骤1:点击“我的”选项卡
        allure.attach('', '点击“我的”选项卡')
        self.page_login.click_my()
        #步骤2:点击“登录/注册”
        allure.attach('', '点击“登录/注册”')
        self.page_login.click_loginreg()
        #步骤3:点击“用UC账号登录”或“切换到旧版登录”
        allure.attach('', '点击“UC”按钮')
        self.page_login.click_uc()
        #步骤4:输入手机号
        allure.attach("输入的数据是" + username, "输入账号")
        self.page_login.input_zanhao(username)
        #步骤5:输入密码
        allure.attach("输入的数据是" + password, "输入密码")
        self.page_login.input_pwd(password)
        #步骤6:点击“登录”按钮
        allure.attach('', '点击“登录”按钮')
        self.page_login.click_login()
        #步骤7:断言登录是否成功
        allure.attach("要找的toast的关键字是:" + toast, "判断某toast是否存在")
        ret = self.page_login.is_toast_exist(toast, True, screen, 20)
        # 步骤8:上传截图图片到Allure测试报告中
        allure.attach(
            open('./screen/' + screen + '.png', 'rb').read(), "本次截图",
            allure.attachment_type.PNG)
        assert ret
Esempio n. 4
0
class TestLogin:
    def setup(self):
        self.driver = init_driver()
        self.pagelogin = PageLogin(self.driver)
    # @pytest.mark.parametrize(("args"),by_file_tars("test_login"))
    @allure.step("步骤1")
    @pytest.mark.parametrize(("args"), by_file_tars("test_login"))
    def test_login(self,args):#,user,password
        username = args["username"]
        password = args["password"]
        toast = args["toast"]
        screen = args["screenshot"]
        allure.attach("输入用户名:"+ username )
        self.pagelogin.input_user(username)
        self.pagelogin.input_password(password)
        self.pagelogin.click_agree()
        self.pagelogin.click_login()
        ret = self.pagelogin.is_toast_exist(toast, True, screen)
        allure.attach(open('./screenshot/' + screen + '.png','rb').read(), 'tupian',allure.attachment_type.PNG)
        assert ret