Пример #1
0
class TestHome:
    def setup(self):
        self.action = Page().init_page_home

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

    def test_enter_page(self):
        self.action.into_page()
        sleep(2)
Пример #2
0
class Test_a:
    def setup_class(self):
        self.driver = init_driver.init_driver()
        self.search_obj = Page(self.driver).return_search_obj()

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

    @pytest.mark.parametrize("test_num,test", data())
    def test_001(self, test_num, test):
        self.search_obj.search_botton()

        self.search_obj.search_input(test)
        sleep(2)
        assert self.driver.get_screenshot_as_file("./screen/%s.png" % test_num)
Пример #3
0
    def test_address_new(self, obj):
        # 进入主界面,通掉用page_home里的页面动作
        Page().init_page_home.into_page()

        # 点击我,通过掉用page_myself里的页面动作
        self.use_myself = Page().init_page_myself
        self.use_myself.click_myself()

        # 判断用户是否登录 通过掉用page_myself里的页面动作
        if not self.use_myself.is_login():
            self.use_myself.click_exist_num()
            self.use_myself.input_num(18610453007)
            self.use_myself.input_pwd(123456)
            self.use_myself.click_login()

        # 点击设置 通过掉用page_myself里的页面动作
        self.use_myself.click_setting()

        # 点击地址管理
        self.action.click_address_manage()

        # 点击 新增地址
        self.action.click_new_address()

        # 输入收件人
        self.action.input_receipt(obj[0])

        # 输入手机号
        self.action.input_phone_num(obj[1])

        # 展开省市区下拉
        self.action.click_area_select()

        # 选择省市区
        self.action.select_area(obj[2], obj[3], obj[4])

        # 输入详细地址
        self.action.input_detail_address(obj[5])

        # 点击保存
        self.action.click_save()
        time.sleep(2)

        # 断言
        self.action.assert_address_add(obj[0], obj[1])
Пример #4
0
class Test_Login():
    def __init__(self):
        text = '此用户'
        self.mess = (By.XPATH, "//*[contains(@text,'{}')]".format(text))

    def setup_class(self):
        self.driver = get_driver(
            "com.yunmall.lc", "com.yunmall.ymctoc.ui.activity.MainActivity")
        self.page_obj = Page(self.driver)

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

    @pytest.fixture(scope='class', autouse=True)
    def click_login_btu(self):
        # 点击我的
        self.page_obj.get_home_page_obj().click_my_btu()
        # 点击已有账号 去登录
        self.page_obj.get_sign_page_obj().click_exits_login_btu()

    def test_login(self):
        self.page_obj.get_login_page_obj().login("1111", '1234')

    def test_get_result(self):
        text = self.page_obj.get_login_page_obj().search_element(
            self.mess, timeout=5, poll_frequency=0.5).text
        print(text)
Пример #5
0
class Test_Trans():
    def setup_class(self):
        self.driver = init_driver()
        self.trans_obj = Page(self.driver).get_trans()

    @allure.step(title="这是登录测试")
    @pytest.mark.parametrize("dir",
                             get_yml_with_filename_key("trans_data",
                                                       "TestData"))
    def test_001(self, dir):
        name = dir["name"]
        phone = dir["phone"]

        allure.attach("输入姓名", name)
        self.trans_obj.input_name(name)

        allure.attach("输入电话", phone)
        self.trans_obj.input_phone(phone)

        allure.attach("提交")
        self.trans_obj.click_submit()

    # def test_002(self):
    #     print(111)
    def teardown_class(self):
        self.driver.quit()
Пример #6
0
class Test():
    def setup_class(self):
        self.a=Page(get_driver())

    def teardown_class(self):
        self.a.driver.quit()
    def test_01(self,username="******",password="******"):
        self.a.page_input_username(username)
        self.a.page_input_password(password)
        self.a.page_cick_btn()
Пример #7
0
class Test_Login():
    def setup_class(self):
        self.driver = init_driver()
        self.login_obj = Page(self.driver).get_login()

    # 输入手机号码
    # 输入密码
    # 判断页面登入是否成功:使用断言方法
    # 每次传入参数直接为一个 列表,可以直接对应3个参数
    # 这种方式 用的比较少,在数据量比较少可以用,但是yml书写比较模糊
    # @pytest.mark.parametrize(("name","pwd","toast"),get_data("TestData"))
    # def test_login(self,name,pwd,toast):
    #     self.login_obj.login_name(name)
    #     self.login_obj.login_pwd(pwd)
    #     self.login_obj.click_login()
    #
    #     assert self.login_obj.is_toast_exit(toast)
    #
    #     print('xxxx')

    # 每次传入的参数是一个字典,使用时需要根据字典的键获取对应值
    # 这种方法用的比较多,因为yml的书写格式 很清晰
    @allure.step(title="这是登录测试")
    @pytest.mark.parametrize("dir",
                             get_yml_with_filename_key("login_data",
                                                       "TestData2"))
    def test_login2(self, dir):
        name = dir["name"]
        password = dir["password"]
        toast = dir["toast"]

        #当有需要新增参数数据时,可以自己再加入yml,读取格式无需修改,很方便
        screen = dir["screen"]

        allure.attach("输入用户名", name)
        self.login_obj.login_name(name)

        allure.attach("输入密码", password)
        self.login_obj.login_pwd(password)

        allure.attach("点击登入")
        self.login_obj.click_login()

        allure.attach("登入结果判断", toast)
        #断言判断,并且进行截图
        # toast_exist= self.login_obj.is_toast_exit(toast,True,screen)
        # #将截图上传到报告中
        # allure.attach("图片",open("./screen/"+screen+".png","rb").read(),allure.attachment_type.PNG)
        # assert toast_exist

    def test_001(self):
        print(111)

    def teardown_class(self):
        self.driver.quit()
Пример #8
0
    def test_address_del(self):
        # 进入主界面
        Page().init_page_home.into_page()

        # 点击我
        Page().init_page_myself.click_myself()

        # 判断用户是否登录
        if not Page().init_page_myself.is_login():
            Page().init_page_myself.click_exist_num()
            Page().init_page_myself.input_num(18610453007)
            Page().init_page_myself.input_pwd(123456)
            Page().init_page_myself.click_login()

        # 点击设置
        self.action.click_setting()

        # 点击地址管理
        self.action.click_address_manage()
        time.sleep(1)

        # 获取删除前的地址条数
        before_del = self.action.get_address_count()

        if not before_del:
            return
        else:
            # 点击编辑
            self.action.click_address_edit()

            # 点击删除
            self.action.click_address_del()

            # 点击确定
            self.action.click_address_confirm()
            time.sleep(1)

        # 获取删除后的地址条数
        after_del = self.action.get_address_count()

        # 断言
        assert before_del - after_del == 1
Пример #9
0
    def test_login_no_num(self, obj):
        Page().init_page_home.into_page()
        # 在这里为了避免被操作的元素还未出现,可以设置强制等待,让主界面内容进行加载渲染
        time.sleep(2)

        # 点击 我
        self.action.click_myself()

        # 点击使用已有账号登录
        self.action.click_exist_num()

        # 输入账号
        self.action.input_num(obj[0])

        # 输入密码
        self.action.input_pwd(obj[1])

        # 点击登录
        self.action.click_login()

        # 断言账号不存在用例执行是否通过
        self.action.assert_toast("此用户不存在")
Пример #10
0
 def setup_class(self):
     # 实例化统一入口类
     self.page_obj = Page(get_driver("com.yunmall.lc","com.yunmall.ymctoc.ui.activity.MainActivity"))
Пример #11
0
from selenium.webdriver.common.by import By

from Base.get_driver import get_phone_driver
from Page.page import Page

# 实例化driver
driver = get_phone_driver("com.yunmall.lc",
                          "com.yunmall.ymctoc.ui.activity.MainActivity")

# 实例化统一入口类
page_obj = Page(driver)

# 点击首页
page_obj.get_homepage().click_my_btn()
# 点击注册页面已有账号登录
page_obj.get_signpage().click_sign()
# 执行登录操作
# page_obj.get_loginpage().login('13488834010','159357li')
"""逆向用例获取"""
page_obj.get_loginpage().login('13488834010', '15935')
# 获取提示消息
# 获取错误提示xpath
error_message = (By.XPATH, '//*[contains(@text,"错误")]')
massage = page_obj.get_settingpage().get_element(error_message,
                                                 timeout=5,
                                                 poll_frequency=0.5).text
print(massage)

# 获取我的优惠券
# print("获取结果:{}".format(page_obj.get_personpage().get_shop_cart()))
# # 点击设置按钮
Пример #12
0
class Test_Login():
    def setup_class(self):
        self.page_obj = Page(
            get_driver("com.yunmall.lc",
                       "com.yunmall.ymctoc.ui.activity.MainActivity"))

    def teardown_class(self):
        self.page_obj.driver.quit()

    @pytest.mark.parametrize(
        "test_num,phone,passwd,tag,tag_mess,expect_result", get_login_data())
    def test_login(self, test_num, phone, passwd, tag, tag_mess,
                   expect_result):
        """
        :param test_num:
        :param phone:
        :param passwd:
        :param tag:
        :param tag_mess:
        :param expect_result:
        :return:
        """
        # 点击我的
        self.page_obj.get_home_page_obj().click_my_btn()
        # 点击已有账号,去登陆
        self.page_obj.get_sign_page_obj().click_exist_btn()
        # 登录操作
        self.page_obj.get_login_page_obj().login(phone, passwd)
        # 判断成功失败用例
        if tag:  # 预期成功的用例
            try:  #断言我的优惠券在不在个人中心页面,如果内容改变也不影响后面退出操作
                # 优惠券
                coupons = self.page_obj.get_person_page_obj().get_con_text()
                try:
                    # 断言
                    assert coupons == expect_result
                except AssertionError as e:
                    print(e.__str__())
                # 执行退出操作
                # 点击设置
                self.page_obj.get_person_page_obj().click_setting_btn()
                self.page_obj.get_setting_page_obj().click_logou_btn()

            except TimeoutException as e:  # 如果预期成功的用例没有登录成功,关闭登录页面
                # 关闭登录页面
                self.page_obj.get_login_page_obj().close_login_page()
                assert False
Пример #13
0
class Test_Login:

    def setup_class(self):
        # 实例化统一入口类
        self.page_obj = Page(get_driver("com.yunmall.lc","com.yunmall.ymctoc.ui.activity.MainActivity"))

    def teardown_class(self):
        # 退出driver
        self.page_obj.driver.quit()

    @pytest.mark.parametrize("test_num,username,password,expect_message,tag,toast_ms", cup_data())
    def test_login(self, test_num,username,password,expect_message,tag,toast_ms):
        """
        :param test_num: 用例编号
        :param username: 用户名
        :param password: 密码
        :param expect_message: 预期结果
        :param toast_ms: toast消息获取文本
        :return:
        """
        # 点击我
        self.page_obj.get_home_page().click_my_btn()
        # 点击已有账户 去登陆
        self.page_obj.get_sign_page().click_exit_account()
        # 登陆操作
        self.page_obj.get_login_page().login(username, password)
        # 断言
        if tag:
            # 执行预期成功
            try:
                # 获取我的优惠券
                coupons_text = self.page_obj.get_person_page().get_coupons_text()
                assert expect_message == coupons_text
                # 点击设置按钮
                self.page_obj.get_person_page().click_setting()
                # 执行退出登录
                self.page_obj.get_setting_page().logot()
            except:
                # 关闭登陆页面
                self.page_obj.get_login_page().close_login_page()
                assert False
        else:
            try:
                # 执行预期失败
                # 获取toast消息
                toast_message = self.page_obj.get_person_page().get_toast(toast_ms)
                # 判断登录是否存在
                login_if_exit = self.page_obj.get_login_page().if_login_btn()
                # 断言
                assert login_if_exit and expect_message == toast_message
            finally:
                # 关闭登陆页面
                self.page_obj.get_login_page().close_login_page()
Пример #14
0
from Page.page import Page
from Base.get_driver import get_driver

page_obj = Page(
    get_driver("com.yunmall.lc",
               "com.yunmall.ymctoc.ui.activity.MainActivity"))

page_obj.get_home_page_obj().click_my_btn()
page_obj.get_sign_page_obj().click_exist_btn()
page_obj.get_login_page_obj().login("111", "123")

page_obj.get_login_page_obj().get_toast('此用户')

page_obj.driver.quit()
Пример #15
0
 def setup_class(self):
     self.driver = init_driver()
     self.login_obj = Page(self.driver).get_login()
Пример #16
0
class Test_Login:
    def setup_class(self):
        self.page_obj = Page(get_driver("com.yunmall.lc", "com.yunmall.ymctoc.ui.activity.MainActivity"))

    def teardown_class(self):
        self.page_obj.driver.quit()

    @pytest.mark.parametrize("test_num,phone,passwd,tag,tag_message,expect_result", get_login_data())
    def test_login(self, test_num, phone, passwd, tag, tag_message, expect_result):
        """
        :param test_num: 用例编号
        :param phone: 输入手机号
        :param passwd: 输入密码
        :param tag: 标记成功用例 1 成功用例  None 失败用例
        :param tag_message: 获取toast消息方法参数
        :param expect_result:预期结果
        :return:
        """
        # 点击我
        self.page_obj.get_home_page_obj().click_my_btn()
        # 点击已有账号,去登录
        self.page_obj.get_sign_page_obj().click_exit_account_btn()
        # 登陆操作
        self.page_obj.get_login_page_obj().login(phone, passwd)
        # 判断成功失败用例
        if tag:
            # 预期成功用例
            try:
                # 优惠券
                coupons = self.page_obj.get_person_page_obj().get_coupons_text()
                try:
                    # 断言
                    assert coupons == expect_result
                except AssertionError as e:
                    print(e.__str__())
                # 执行退出操作
                # 点击设置
                self.page_obj.get_person_page_obj().click_setting_btn()
                # 退出
                self.page_obj.get_setting_page_obj().click_logout_btn()

            except TimeoutException as e:
                # 关闭登录页面
                self.page_obj.get_login_page_obj().close_login_page()
                assert False

        else:
            # 预期失败的用例
            try:
                # 获取toast消息
                toast_message = self.page_obj.get_login_page_obj().get_toast(tag_message)
                # 获取登录按钮是否存在
                if_login = self.page_obj.get_login_page_obj().if_login_btn_exits()
                # 断言
                assert if_login and toast_message == expect_result

            except TimeoutException as e:
                assert False

            finally:
                # 关闭登录页面
                self.page_obj.get_login_page_obj().close_login_page()
Пример #17
0
 def setup(self):
     self.action = Page().init_page_home
Пример #18
0
class TestAddress:
    def setup(self):
        self.action = Page().init_page_address

    # @pytest.mark.skip()
    @pytest.mark.parametrize("obj", get_data("address", "address_new"))
    def test_address_new(self, obj):
        # 进入主界面,通掉用page_home里的页面动作
        Page().init_page_home.into_page()

        # 点击我,通过掉用page_myself里的页面动作
        self.use_myself = Page().init_page_myself
        self.use_myself.click_myself()

        # 判断用户是否登录 通过掉用page_myself里的页面动作
        if not self.use_myself.is_login():
            self.use_myself.click_exist_num()
            self.use_myself.input_num(18610453007)
            self.use_myself.input_pwd(123456)
            self.use_myself.click_login()

        # 点击设置 通过掉用page_myself里的页面动作
        self.use_myself.click_setting()

        # 点击地址管理
        self.action.click_address_manage()

        # 点击 新增地址
        self.action.click_new_address()

        # 输入收件人
        self.action.input_receipt(obj[0])

        # 输入手机号
        self.action.input_phone_num(obj[1])

        # 展开省市区下拉
        self.action.click_area_select()

        # 选择省市区
        self.action.select_area(obj[2], obj[3], obj[4])

        # 输入详细地址
        self.action.input_detail_address(obj[5])

        # 点击保存
        self.action.click_save()
        time.sleep(2)

        # 断言
        self.action.assert_address_add(obj[0], obj[1])

    @pytest.mark.skip()
    def test_address_del(self):
        # 进入主界面
        Page().init_page_home.into_page()

        # 点击我
        Page().init_page_myself.click_myself()

        # 判断用户是否登录
        if not Page().init_page_myself.is_login():
            Page().init_page_myself.click_exist_num()
            Page().init_page_myself.input_num(18610453007)
            Page().init_page_myself.input_pwd(123456)
            Page().init_page_myself.click_login()

        # 点击设置
        self.action.click_setting()

        # 点击地址管理
        self.action.click_address_manage()
        time.sleep(1)

        # 获取删除前的地址条数
        before_del = self.action.get_address_count()

        if not before_del:
            return
        else:
            # 点击编辑
            self.action.click_address_edit()

            # 点击删除
            self.action.click_address_del()

            # 点击确定
            self.action.click_address_confirm()
            time.sleep(1)

        # 获取删除后的地址条数
        after_del = self.action.get_address_count()

        # 断言
        assert before_del - after_del == 1

    @pytest.mark.skip()
    def test_address_del_all(self):
        # 进入主界面
        Page().init_page_home.into_page()

        # 点击我
        Page().init_page_myself.click_myself()

        # 判断用户是否登录
        if not Page().init_page_myself.is_login():
            Page().init_page_myself.click_exist_num()
            Page().init_page_myself.input_num(18610453007)
            Page().init_page_myself.input_pwd(123456)
            Page().init_page_myself.click_login()

        # 点击设置
        self.action.click_setting()

        # 点击地址管理
        self.action.click_address_manage()
        time.sleep(1)

        # 获取删除前的地址条数
        before_del = self.action.get_address_count()
        print(before_del)

        # 执行删除
        for i in range(before_del):
            # 点击编辑
            self.action.click_address_edit()
            # 点击删除
            self.action.click_address_del()
            # 点击确认
            self.action.click_address_confirm()
            time.sleep(1)

        # 获取删除后的地址条数
        after_del = self.action.get_address_count()
        print(after_del)

        # 断言
        assert after_del == 0
Пример #19
0
 def setup_class(self):
     # 初始化driver
     self.driver = get_phone_driver(
         "com.yunmall.lc", "com.yunmall.ymctoc.ui.activity.MainActivity")
     # 初始化统一入口类
     self.page_obj = Page(self.driver)
Пример #20
0
 def setup(self):
     self.driver = init_driver()
     self.page = Page(self.driver)
     self.users = self.page.initloginpage.create_phone()
     self.user = str(self.users)
Пример #21
0
 def setup_class(self):
     # 实例化统一入口类
     self.page_obj = Page(init_driver())
Пример #22
0
class Test_Login:

    def setup_class(self):
        # 实例化统一入口类
        self.page_obj = Page(init_driver())

    def teardown_class(self):
        self.page_obj.driver.quit()
    @pytest.mark.parametrize("test_num, name, passwd, tag, get_mes, expect_data", yml_data())
    def test_login(self,test_num, name, passwd, tag, get_mes, expect_data):
        # 登录
        """
        登陆步骤:
            1.点击我
            2.点击已有账户
            3.登陆页面输入登陆信息
            if 登录成功:
                退出操作
            if 登录失败:
                继续输入
        :param name:
        :param passwd:
        :param expect_data:
        :param tag:判断是否是登陆成功用例
        :return:
        """
        # 点击我
        self.page_obj.get_home_page_obj().click_my_btn()
        # 点击已有账号
        self.page_obj.get_sign_page_obj().click_exits_accout()
        # 登陆操作
        self.page_obj.get_login_page_obj().login(name, passwd)
        if tag:
            try:
                # 全部订单是否存在
                all_order = self.page_obj.get_person_page_obj().get_all_order_status()
                # 点击设置按钮
                self.page_obj.get_person_page_obj().click_setiing_btn()
                # 退出操作
                self.page_obj.get_setting_page_obj().click_logout_btn()
                # 断言全部订单
                assert all_order
            except:
                # 关闭登陆页面
                self.page_obj.get_login_page_obj().close_login_page()
                assert False
        else:
            try:
                # 获取toast消息
                toast_message = self.page_obj.get_login_page_obj().get_toast(get_mes)
                # 登陆按钮是否存在
                login_btn = self.page_obj.get_login_page_obj().login_btn_status()
                # 判断提示信息
                assert toast_message == expect_data and login_btn
            finally:
                # 关闭当前登陆页面
                self.page_obj.get_login_page_obj().close_login_page()
Пример #23
0
class Test:
    def setup_class(self):
        self.page_obj = Page(
            get_driver('com.yunmall.lc',
                       'com.yunmall.ymctoc.ui.activity.MainActivity'))

    def teardown_class(self):
        self.page_obj.driver.quit()

    @pytest.fixture(autouse=True)
    def goto_login(self):
        self.page_obj.get_homepage().click_my_btn()
        self.page_obj.get_choice_page().click_login_exist()

    @pytest.mark.parametrize("caseNo,username,password,excp",
                             get_data().get('suc'))
    def test_login_suc(self, caseNo, username, password, excp):
        self.page_obj.get_login_page().Login_in(username, password)  # 登录
        try:
            res = self.page_obj.get_personal_page().get_per_text()
            try:  # 断言
                assert res == excp
            except AssertionError:  # 断言失败
                self.page_obj.get_login_page().get_screen_shot()  # 截图
                assert False
            finally:

                self.page_obj.get_personal_page().click_setting()  # 点击设置
                self.page_obj.get_setting().click_quit()  # 退出操作
        except TimeoutException:
            self.page_obj.get_login_page().get_screen_shot()  # 截图
            self.page_obj.get_login_page().close_page()
            assert False

    @pytest.mark.parametrize("caseNo,username,password,toast,excp",
                             get_data().get('fail'))
    def test_login_fail(self, caseNo, username, password, toast, excp):
        """

        :param caseNo: 用例编号
        :param username: 账号
        :param password: 密码
        :param toast: 提示信息
        :param excp: 预期结果
        :return:
        """
        self.page_obj.get_login_page().Login_in(username, password)  # 登录
        try:
            """找到toast"""
            res = self.page_obj.get_login_page().get_toast_msg(
                toast)  # 获取toast消息
            try:
                assert res == excp  # 断言
            except AssertionError:
                self.page_obj.get_login_page().get_screen_shot()  # 截图
                assert False
        except TimeoutException:
            self.page_obj.get_login_page().get_screen_shot()  # 截图
            assert False
        finally:
            try:
                """登录按钮是否存在"""
                self.page_obj.get_login_page().if_login_btn()  # 判断登录按钮
                self.page_obj.get_login_page().close_page()  # 关闭登录页面
            except TimeoutException:
                """登录按钮不存在"""
                self.page_obj.get_personal_page().click_setting()  # 点击设置
                self.page_obj.get_setting().click_quit()  # 退出页面
                assert False
Пример #24
0
class TestLogin:
    def setup_class(self):
        # 初始化driver
        self.driver = get_phone_driver(
            "com.yunmall.lc", "com.yunmall.ymctoc.ui.activity.MainActivity")
        # 初始化统一入口类
        self.page_obj = Page(self.driver)

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

    @pytest.fixture(autouse=True)
    def auto_in_login(self):
        # 点击我
        self.page_obj.get_home().click_my_btn()
        # 点击已有账号
        self.page_obj.get_sign().click_exits_account()

    @pytest.mark.parametrize("case_num,account, passwd, expect_data",
                             get_login_data().get("suc"))
    def test_login_suc(self, case_num, account, passwd, expect_data):
        """
        :param case_num: 用例编号
        :param account: 用户名
        :param passwd: 密码
        :param exp_data: 预期结果
        :return:
        """
        #登录操作 --个人中心
        self.page_obj.get_login().login(account, passwd)
        try:
            # 获取我的优惠
            shop_cart = self.page_obj.get_person().get_shop_cart()
            try:
                assert expect_data == shop_cart
            except AssertionError:
                """停留在个人中心,需要执行退出操作"""
                # 截图
                self.page_obj.get_login().screen_page()
                assert False
            finally:
                # 点击设置
                self.page_obj.get_person().click_setting_btn()
                # 退出操作
                self.page_obj.get_setting().logout()
        except TimeoutException:
            # 截图
            self.page_obj.get_login().screen_page()
            # 关闭页面
            self.page_obj.get_login().login_close_page()
            assert False

    @pytest.mark.parametrize("case_num, account, passwd, toast, expect_data",
                             get_login_data().get("fail"))
    def test_login_fail(self, case_num, account, passwd, toast, expect_data):
        """
        :param case_num:用例编号
        :param account:用户名
        :param passwd:密码
        :param toast:获取toast消息
        :param exp_data:预期结果
        :return:
        """
        # 登录操作 --个人中心
        self.page_obj.get_login().login(account, passwd)
        try:
            #获取toast消息
            toast_data = self.page_obj.get_setting().get_toast(toast)
            try:
                # 登录页面
                # 判断登录按钮是否存在
                self.page_obj.get_login().if_login_btn()
                # 断言
                assert toast_data == expect_data
                # 关闭登录页面
                self.page_obj.get_login().login_close_page()
            except TimeoutException:
                # 获取toast错误信息,但登录成功
                # 截图
                self.page_obj.get_login().screen_page()
                # 点击设置
                self.page_obj.get_person().click_setting_btn()
                # 退出
                self.page_obj.get_setting().logout()
                assert False
            except AssertionError:
                # 登录页面
                # 截图操作
                self.page_obj.get_setting().screen_page(name="断言失败")
                # 关闭登录按钮
                self.page_obj.get_login().login_close_page()
                assert False

        except TimeoutException:
            # 找不到toast
            # 截图
            self.page_obj.get_setting().screen_page(name="未找到")
            try:
                # 登录页面
                # 登录按钮
                self.page_obj.get_login().if_login_btn()
                # 关闭登录页面
                self.page_obj.get_login().login_close_page()
            except TimeoutException:
                # 个人中心页面
                # 点击设置
                self.page_obj.get_person().click_setting_btn()
                # 退出操作
                self.page_obj.get_setting().logout()
            assert False
Пример #25
0
 def setup_class(self):
     self.page_obj = Page(
         get_driver('com.yunmall.lc',
                    'com.yunmall.ymctoc.ui.activity.MainActivity'))
Пример #26
0
 def setup_class(self):
     self.driver = init_driver.init_driver()
     self.search_obj = Page(self.driver).return_search_obj()
Пример #27
0
class Test_Login:
    def setup_class(self):
        self.page_obj = Page(
            get_driver("com.yunmall.lc",
                       "com.yunmall.ymctoc.ui.activity.MainActivity"))

    def teardown_class(self):
        self.page_obj.driver.quit()

    @allure.step(title='预期成功用例')
    @pytest.mark.parametrize(
        "test_num,phone,passwd,tag,tag_message,expect_result",
        get_login_data())
    def test_login(self, test_num, phone, passwd, tag, tag_message,
                   expect_result):
        """

        :param test_num: 用例编号
        :param phone: 输入手机号
        :param passwd: 输入密码
        :param tag: 标记成功用例 1 成功用例  None 失败用例
        :param tag_message: 获取toast消息方法参数
        :param expect_result:预期结果
        :return:
        """
        # 点击我的
        self.page_obj.get_home_page_obj().click_my_btu()
        # 点击已有账号去登录
        self.page_obj.get_sign_page_obj().click_exits_login_btu()
        # 输入用户名 密码 点击登录
        self.page_obj.get_login_page_obj().login(phone, passwd)

        if tag:  # tag==1 为True 即为预期成功
            try:
                # 获取优惠卷文本
                coupons = self.page_obj.get_person_page_obj(
                ).get_person_coupons_text()
                # 但是 优惠卷名称可能会发生改变 但是如果取到这个文本即代表跳转至个人中心页-登录成功
                # 把断言放在try中,不会因为取到元素,但是断言失败而出错
                try:
                    assert coupons == expect_result
                except AssertionError as e:
                    # 打印断言错误信息
                    print(e.__str__())
                # 点击设置 点击退出
                self.page_obj.get_person_page_obj().click_setting()
                self.page_obj.get_setting_page_obj().login_out(1)
            except TimeoutError as e:
                # 如果没有跳转至个人中心页  也会用15秒的固定时间来搜索 优惠卷文本--找不到就会报超时异常
                # 即为还留在登录页  点击登录页上的退出按钮-进行退出操作
                self.page_obj.get_login_page_obj().close_login_btu()

        else:  # tag 找不到 即为预期失败用例
            pass
Пример #28
0
 def setup_class(self):
     self.a=Page(get_driver())
Пример #29
0
 def setup(self):
     self.action = Page().init_page_address
Пример #30
0
from selenium.webdriver.common.by import By

from Page.page import Page
from Base.get_driver import get_driver

page_obj = Page(
    get_driver('com.yunmall.lc',
               'com.yunmall.ymctoc.ui.activity.MainActivity'))
# 点击我
page_obj.get_homepage().click_my_btn()
# 选择已注册账号
page_obj.get_choice_page().click_login_exist()
# 输入
page_obj.get_login_page().Login_in('18796773314', '1234567')
# msg = (By.XPATH, '//*[contains(@text,"密码错误")]')
# print(page_obj.get_login_page().get_element(msg, timeout=6, poll_frequency=0.5).text)
print(page_obj.get_login_page().get_toast_msg('密码错误'))
# # 个人页面
# page_obj.get_personal_page().get_per_text()
# page_obj.get_personal_page().click_setting()
# # 退出页面
# page_obj.get_setting().click_quit()