示例#1
0
class TestMpLogin:
    # 初始化
    def setup_class(self):

        # 1:获取driver
        driver = GetDriver.get_web_driver(page.url_mp)
        # 2:获取统一入口类获取类
        self.mp = PageIn(driver).page_get_PageMpLogin()
        pass

    # 结束"
    def teardown_class(self):
        # 调用关闭driver
        GetDriver.quit_web_driver()
        pass

    # 测试业务方法
    @pytest.mark.parametrize("username, code, expect",
                             readyaml("mp_login.yml"))
    def test_mp_login(self, username, code, expect):

        try:
            # 调用登录业务方法
            self.mp.page_mp_login(username, code)
            # 断言
            assert expect == self.mp.page_get_nickname()
        except Exception as e:
            print("错误原因", e)
            self.mp.base_get_img()
            raise
class TestAppArticle:
    # 1.初始化
    def setup(self):
        # 1.获取driver
        driver = GetDriver.get_app_driver()
        # 2.获取页面统一入口对象
        self.page_in = PageIn(driver)
        # 3.调用登录成功方法
        self.page_in.page_get_PageAppLogin().page_app_login_success()
        # 4.获取PageAppArticle对象
        self.article = self.page_in.page_get_PageAppArticle()

    # 2.结束
    def teardown(self):
        # 关闭driver
        GetDriver.quit_app_driver()

    # 3.文章测试方法
    @pytest.mark.parametrize("data", read_yaml("app_article.yaml"))
    def test_app_article(self, data):
        channel = data['channel']
        title = data['title']
        try:
            # 调用文章业务方法
            self.article.page_app_article(channel, title)
        except Exception as e:
            # 1.日志
            log.error("断言出错,错误原因:{}".format(e))
            # 2.截图
            self.article.base_get_img()
            # 3.抛出异常
            raise
class TestMpLogin:
    # 初始化

    def setup_class(self):
        # 1、获取driver
        driver = GetDriver().get_web_driver(page.url_mp)
        # 2、通过统一入口类获取PageMpLogin对象
        self.mp = PageIn(driver).page_get_PageMpLogin()

    # 结束
    def teardown_class(self):
        # 关闭driver
        GetDriver.quit_web_driver()

    # 测试业务方法
    @pytest.mark.parametrize("username,code,expect",
                             read_yaml("mp_login.yaml"))
    def test_mp_login(self, username, code, expect):
        # 调用登录方法
        self.mp.page_mp_login(username, code)
        # 断言
        sleep(3)  # 解决 还未跳转到成功页面,获取昵称错误的问题
        try:
            assert expect == self.mp.page_get_nickname()
        except Exception as e:
            log.error("自媒体登录断言出错,错误信息 :{}".format(e))
            print("错误的原因:", e)
            #截图
            self.mp.base_get_image()
            # 抛异常
            raise
class TestMisLogin:
    def setup_class(self):
        self.driver = GetDriver.get_driver(page.url_mis)
        # 获取PageMpLogin对象
        self.mis_login = PageIn(self.driver).page_get_PageMisLogin()
        print("参数化读取数据为:", read_yaml("mis_login.yaml"))

    def teardown_class(self):
        # 关闭driver
        GetDriver.quit_driver()

    @pytest.mark.parametrize("username,password,expect",
                             read_yaml("mis_login.yaml"))
    def test_mis_login(self, username, password, expect):
        # 调用登录业务方法
        self.mis_login.page_mis_login(username, password)
        try:
            # 断言
            assert expect == self.mis_login.page_get_nickname()
        except Exception as e:
            # 日志
            log.error(e)
            # 截图
            self.mis_login.base_get_img()
            # 抛异常
            raise
class TestMisAudit:
    # 初始化
    def setup_class(self):
        # 1. 获取driver
        driver = GetDriver.get_web_driver(page.url_mis)
        # 2. 获取统一入口类对象
        self.page_in = PageIn(driver)
        # 3. 调用登录成功依赖对象
        self.page_in.page_get_PageMisLogin().page_mis_login_success()
        # 4. 获取PageMisAudit对象
        self.audit = self.page_in.page_get_PageMisAudit()

    # 结束
    def teardown_class(self):
        # 关闭driver
        GetDriver.quit_web_driver()

    # 审核文章业务测试方法
    def test_mis_audit(self, title=page.title, channel=page.channel):
        # 调用审核文章业务方法
        self.audit.page_mis_audit(title, channel)
        try:
            # 断言
            assert self.audit.page_assert_audit()
        except Exception as e:
            # 1. 日志
            log.error(e)
            # 2. 截图
            self.audit.base_get_img()
            # 3. 抛异常
            raise
示例#6
0
class TestMpArticle:
    # 初始化
    def setup_class(self):
        # 获取driver
        driver = GetDriver.get_driver(page.url_mp)
        # 获取统一入口类
        self.page = PageIn(driver)
        # 调用登录业务成功方法
        self.page.page_get_PageMpLogin().page_mp_login_success()
        # 获取PageMpArticle对象
        self.article = self.page.page_get_PageMpArticle()

    # 结束
    def teardown_class(self):
        # 关闭driver
        GetDriver.quit_driver()

    # 测试发布文章业务方法
    def test_mp_article(self,
                        title="bj-test17-006",
                        content="测试发布文章!",
                        expect="新增文章成功"):
        # 调用发布文章业务方法
        self.article.page_publish_article(title, content)
        try:
            # 断言
            assert expect == self.article.page_get_commit_result()
        except Exception as e:
            # 日志
            log.error(e)
            # 截图
            self.article.base_get_img()
            # 抛异常
            raise
class TestMpArticle:
    # 初始化
    def setup_class(self):
        # 获取driver
        driver = GetDriver().get_web_driver(page.url_mp)
        # 获取统一入口类对象
        self.page_in = PageIn(driver)
        # 获取PageMpLogin对象并调用成功登录依赖方法
        self.page_in.page_get_PageMpLogin().page_mp_login_success()
        # 获取PageMpArticle页面对象
        self.mp_article = self.page_in.page_get_PageMpArticle()
        #

    # 结束
    def teardown_class(self):
        # 关闭driver
        GetDriver().quit_web_driver()

    # 发表文章测试方法
    @pytest.mark.parametrize("title,content,expect",
                             read_yaml("mp_article.yaml"))
    def test_mp_article(self, title, content, expect):
        # 调用发布文章业务
        self.mp_article.page_mp_publish_article(title, content)
        #       #获取结果信息
        info = self.mp_article.page_get_info()
        print("文章发布结果:", info)
        # 断言
        try:
            assert info == expect
        except Exception as e:
            log.error("发布文章错误原因", e)
            print("发表文章错误信息:", e)
            self.mp_article.base_get_image()
            raise
class TestAppLogin:
    # 初始化
    def setup_class(self):
        # 获取driver
        driver = GetDriver.get_app_driver()
        # 通过统一入口对象获取PageAppLogin对象
        self.login = PageIn(driver).page_get_PageAppLogin()

    # 结束
    def teardown_class(self):
        GetDriver.quite_app_driver()

    # app登录测试业务方法
    @pytest.mark.parametrize("phone,code", read_yaml("app_login.yaml"))
    def test_app_login(self, phone, code):
        # 调用app登录业务方法
        self.login.page_app_login(phone, code)
        # 调试断言
        try:
            assert self.login.page_is_login_success()
        except Exception as e:
            # 日志
            log.error(e)
            # 截图
            self.login.base_get_img()
            raise
示例#9
0
class TestMisAudit:
    # 初始化
    def setup_class(self):
        # 获取driver
        driver = GetDriver.get_driver(page.url_mis)
        # 获取 统一入口类
        self.page_in = PageIn(driver)
        # 调用登录业务成功方法(需要在PageMisLogin新增)
        self.page_in.page_get_PageMisLogin().page_mis_login_success()
        # 获取PageMisAudit对象
        self.audit = self.page_in.page_get_PageMisAudit()

    # 结束
    def teardown_class(self):
        sleep(5)
        # 关闭driver
        GetDriver.quit_driver()

    # 审核文章测试方法
    def test_article_audit(self, title=page.article_title, channel=page.article_channel):
        # 调用审核业务方法
        self.audit.page_mis_audit(title, channel)
        try:
            # 断言
            assert self.audit.page_assert_success(title="bj-test17-004", channel="数据库")
        except Exception as e:
            # 日志
            log.error(e)
            # 截图
            self.audit.base_get_img()
            # 抛异常
            raise
示例#10
0
class TestMpLogin:
    # 初始化
    def setup_class(self):
        driver = GetDriver.get_web_driver(page.url_mp)
        # 通过统一入口类获取PageMpLogin对象
        self.mp = PageIn(driver).page_get_PageMpLogin()

    # 结束
    def teardown_class(self):
        GetDriver.quit_web_driver()

    # 测试
    @pytest.mark.parametrize("username,code, expect",
                             read_yaml("mp_login.yaml"))
    def test_mp_login(self, username, code, expect):
        print("test")
        self.mp.page_mp_login(username, code)
        try:
            #断言
            assert expect == self.mp.page_get_nickname()
        except Exception as e:
            #输出错误信息
            log.error("断言出错,错误信息:{}".format(e))
            print("错误原因:", e)
            #截图
            self.mp.base_get_image()
            #抛异常
            raise
class TestMpLogin:
    # 初始化
    def setup_class(self):
        # 1. 获取driver
        driver = GetDriver.get_web_driver(page.url_mp)
        # 2. 通过统一入口类获取PageMpLogin对象
        self.mp = PageIn(driver).page_get_PageMpLogin()

    # 结束
    def teardown_class(self):
        # 调用关闭driver
        GetDriver.quit_web_driver()

    # 测试业务方法
    @pytest.mark.parametrize("username, code, expect", read_yaml("mp_login.yaml"))
    def test_mp_login(self, username, code, expect):
        # 调用登录业务方法
        self.mp.page_mp_login(username, code)
        # 断言
        try:
            assert expect == self.mp.page_get_nickname()
        except Exception as e:
            log.error("断言出错,错误信息:{}".format(e))
            # 输出错误信息
            print("错误信息:", e)
            # 截图
            self.mp.base_get_img()
            # 抛出异常
            raise
示例#12
0
class TestMpLogin:
    # 初始化
    def setup_class(self):
        # 获取driver
        self.driver = GetDriver.get_driver(page.url_mp)
        # 获取PageMpLogin对象
        self.login = PageIn(self.driver).page_get_PageMpLogin()
        print("参数化读取数据为:", read_yaml("mp_login.yaml"))

    # 结束
    def teardown_class(self):
        # 关闭driver
        GetDriver.quit_driver()

    # 测试业务方法
    # 把数据改成expect="13812345678-,会抛出异常并截图
    @pytest.mark.parametrize("phone,code,expect", read_yaml("mp_login.yaml"))
    # def test_mp_login(self, phone="13812345678", code="246810", expect="13812345678"):
    def test_mp_login(self, phone, code, expect):
        # 调用登录业务方法
        self.login.page_mp_login(phone, code)
        try:
            # 断言
            # print("获取的昵称为:", self.login.page_get_nickname())
            assert expect == self.login.page_get_nickname()  # 坑坑坑,,没有指定异常信息
        except Exception as e:
            # 日志 9+++++++
            log.error(e)
            # 截图
            self.login.base_get_img()
            # 抛异常
            raise
class TestAppArticle:
    # 初始化
    def setup_class(self):
        driver = GetDriver.get_app_driver()
        self.page_in = PageIn(driver)
        self.page_in.page_get_PageAppLogin().page_app_login_success()
        self.article = self.page_in.page_get_PageAppArticle()

    # 结束
    def teardown_class(self):
        GetDriver.quit_app_driver()

    # 测试业务
    @pytest.mark.parametrize(('find_text', 'title'),
                             read_yaml('app_article.yaml'))
    def test_app_article(self, find_text, title):
        try:
            # 调用发布文章业务方法
            self.article.page_app_article(find_text, title)
        except Exception as e:
            # 日志
            log.error(e)
            # 截图
            self.article.base_get_img()
            # 抛出异常
            raise
示例#14
0
 def setup_class(self):
     self.page_login = PageIn.get_page_login()
     self.page_address = PageIn.get_page_address()
     # 点击不更新
     self.page_login.page_click_x()
     # 登录方法
     self.page_login.page_login_address()
示例#15
0
class TestMisLogin:
    # 1.初始化
    def setup(self):
        # 1.获取driver
        driver = GetDriver.get_web_driver('chrome', page.mis_url)
        # 2.通过统一入口类对象获取PageMisLogin对象
        self.mis = PageIn(driver).page_get_PageMisLogin()

    # 2.销毁
    def teardown(self):
        # 关闭driver
        GetDriver.quit_web_driver()

    # 3.登录业务测试方法
    @pytest.mark.parametrize("data", read_yaml("mis_login.yaml"))
    def test_mis_login(self, data):
        username = data['username']
        pwd = data['password']
        expect = data['expect']
        # 调用登录业务方法
        self.mis.page_mis_login(username=username, pwd=pwd)
        # 调试断言信息
        try:
            assert expect in self.mis.page_get_nickname()
        except Exception as e:
            # 日志
            log.error("断言出错,出错原因:{}".format(e))
            # 截图
            self.mis.base_get_img()
            # 异常抛出
            raise
示例#16
0
class TestMpLogin:
    # 初始化
    def setup_class(self):
        # 获取driver
        self.driver = GetDriver.get_driver(page.url_mp)
        # 获取PageMpLogin对象
        self.login = PageIn(self.driver).page_get_PageMpLogin()
        print("参数化读取数据为:", read_yaml("mp_login.yaml"))

    # 结束
    def teardown_class(self):
        # 关闭driver
        GetDriver.quit_driver()

    # 测试业务方法
    @pytest.mark.parametrize("phone,code,expect", read_yaml("mp_login.yaml"))
    def test_mp_login(self, phone, code, expect):
        # 调用登录业务方法
        self.login.page_mp_login(phone, code)
        try:
            # 断言
            assert expect == self.login.page_get_nickname()
        except Exception as e:
            # 日志
            log.error(e)
            # 截图
            self.login.base_get_img()
            # 抛异常
            raise
示例#17
0
class TestMisLogin:
    # 1. 初始化
    def setup_class(self):
        # 1. 获取driver
        driver = GetDriver.get_web_driver(page.url_mis)
        # 2. 通过统一入口类对象获取PageMisLogin
        self.mis = PageIn(driver).page_get_PageMisLogin()

    # 2. 结束
    def teardown_class(self):
        # 关闭driver
        GetDriver.quit_web_driver()

    # 3. 登录测试业务方法
    @pytest.mark.parametrize("username,pwd,expect",
                             read_yaml("mis_login.yaml"))
    def test_mis_login(self, username, pwd, expect):
        # 1. 调用登录业务方法
        self.mis.page_mis_login(username, pwd)
        try:
            # 2. 调试断言信息
            assert expect in self.mis.page_get_nickname()
        except Exception as e:
            # 日志
            log.error(e)
            # 截图
            self.mis.base_get_img()
            # 抛异常
            raise
示例#18
0
 def test01_add_hair(self, money, demand):
     self.hair = PageIn().page_get_page_add_order()
     self.hair.page_hair(money, demand)
     self.hair.page_login_me()
     self.hair.page_click_hair_billing_record()
     sleep(2)
     self.hair.if_order()
示例#19
0
class TestMisAudit:
    # 1.初始化
    def setup(self):
        # 1.获取driver
        driver = GetDriver.get_web_driver('chrome', page.mis_url)
        # 2.获取统一入口类对象
        self.page_in = PageIn(driver)
        # 3.通过统一入口类对象获取PageMisLogin对象并调用登录成功方法
        self.page_in.page_get_PageMisLogin().page_mis_login_success()
        # 4.获取PageMisAudit对象
        self.mis = self.page_in.page_get_PageMisAudit()

    # 2.退出
    def teardown(self):
        GetDriver.quit_web_driver()

    # 3.测试脚本
    def test_mis_audit(self, title=page.title, channel=page.channel):
        # 调用审核文章业务方法
        self.mis.page_mis_audit(title, channel)
        # 断言处理
        try:
            assert self.mis.page_audit_assert()
        except Exception as e:
            # 1.日志
            log.error("断言出错,错误信息:{}".format(e))
            # 2.截图
            self.mis.base_get_img()
            # 3.抛异常
            raise
class TestMpArticle:
    # 初始化
    def setup_class(self):
        # 获取driver
        driver = GetDriver.get_web_driver(page.url_mp)
        # 获取统一入口类对象
        self.page_in = PageIn(driver)
        # 获取PageMpLogin对象并调用成功登录依赖方法
        self.page_in.page_get_PageMpLogin().page_mp_login_success()
        # 获取PageMpArticle对象
        self.article = self.page_in.page_get_PageMpArticle()

    # 结束
    def teardown_class(self):
        # 关闭driver
        GetDriver.quit_web_driver()

    # 发布文章方法
    @pytest.mark.parametrize("title,content,expect,channel",
                             read_yaml("mp_article.yaml"))
    def test_mp_article(self, title, content, expect, channel):
        print("发布文章所属频道为: ", channel)
        # 调用发布文章业务信息方法
        self.article.page_mp_article(title, content)
        try:
            # 断言
            assert expect in self.article.page_get_info()
        except Exception as e:
            # 日志
            log.error(e)
            # 截图
            self.article.base_get_img()
            # 抛异常
            raise
示例#21
0
class TestMpArticle:
    # 初始化
    def setup_class(self):
        # 获取driver
        driver = GetDriver.get_driver(page.mp_url)
        # 获取统一入口类对象
        self.page_in = PageIn(driver)
        # 获取PageMpLogin对象并调用成功登录依赖方法
        self.page_in.page_get_PageMpLogin().page_my_login_success()
        # 获取PageMpArticle页面对象
        self.article = self.page_in.page_get_PageMpArticle()

    # 结束
    def teardown_class(self):
        sleep(2)
        GetDriver.quit_driver()

    # 测试发布文章业务方法
    @pytest.mark.parametrize('title, content, expect, screenshot_name, channel', read_yaml('mp_article.yaml'))
    def test_mp_article(self, title, content, expect, screenshot_name):
        # 调用发布文章业务方法
        self.article.page_mp_article(title, content)
        try:
            assert expect == self.article.page_get_message()
            print(self.article.page_get_message())
        except Exception as e:
            log.error('断言 发布文章失败, 失败信息为: {}'.format(e))
            # print('错误原因:', e)
            # 截图
            self.article.base_screenshot(screenshot_name)
            # 抛出异常
            raise
示例#22
0
class TestMisAudit:
    # 初始化
    def setup_class(self):
        # 获取driver
        driver = GetDriver.get_web_driver(page.url_mis)
        # 统一入口类对象
        self.page_in = PageIn(driver)
        # 登陆成功依赖
        self.page_in.page_get_PageMisLogin().page_mis_login_success()
        # 获取调用对象
        self.audit = self.page_in.page_get_PageMisAudit()

    # 结束
    def teardown_class(self):
        GetDriver.quit_web_driver()

    # 审核文章业务测试方法
    def test_mis_audit(self, title=page.title, channel=page.channel):
        # 调用审核文章业务方法
        self.audit.page_mis_audit(title, channel)
        # 调用断言业务操作方法
        try:
            assert self.audit.page_assert_audit()
        except Exception as e:
            # 日志
            log.error(e)
            # 截图
            self.audit.base_get_img()
            # 抛出异常
            raise
class TestMpArticle:
    # 1. 初始化
    def setup_class(self):
        # 1. 获取driver
        driver = GetDriver.get_web_driver(page.url_mp)
        # 2. 获取统一入口类对象
        self.page_in = PageIn(driver)
        # 3. 获取PageMpLogin对象并调用成功登录依赖方法
        self.page_in.page_get_PageMpLogin().page_mp_login_success()
        # 4. 获取PageMpArticle页面对象
        self.article = self.page_in.page_get_PageMpArticle()

    # 2. 结束
    def teardown_class(self):
        GetDriver.quit_web_driver()

    # 3. 测试发布文章方法
    @pytest.mark.parametrize(('title', 'content', 'expect', 'channel'),
                             read_yaml('mp_article.yaml'))
    def test_mp_article(self, title, content, expect, channel):
        print("发布文章所属频道为:", channel)
        # 调用发布文章业务方法
        self.article.page_mp_article(title, content)
        try:
            # 断言
            assert expect == self.article.page_get_info()
        except Exception as e:
            # 日志
            log.error(e)
            # 截图
            self.article.base_get_img()
            # 抛出异常
            raise
示例#24
0
 def setup_class(self):
     # 获取PageLogin对象
     self.login = PageIn().page_get_PageLogin()
     # 点击我
     self.login.page_click_me()
     # 点击已有账号去登录
     self.login.page_click_account_link()
class TestMisAudit:
    # 初始化
    def setup_class(self):
        # 获取driver
        driver = GetDriver.get_web_driver(page.url_mis)
        # 获取统一入口类对象
        self.page_in = PageIn(driver)
        # 调用登录成功依赖方法
        self.page_in.page_get_PageMisLogin().page_mis_login_success()
        # 获取PageMisAudit对象
        self.audit = self.page_in.page_get_PageMisAudit()

    # 结束
    def teardown_class(self):
        GetDriver.quit_web_driver()

    # 审核文章业务测试方法
    def test_mis_audit(self, title=page.title, channel=page.channel):
        # 调用审核文章业务测试方法
        self.audit.page_mis_audit(title, channel)
        # 断言
        try:
            assert self.audit.page_assert_audit()
        except Exception as e:
            # 日志
            log.error("断言出错,错误信息:{}".format(e))
            # 截图
            self.audit.base_get_img()
            # 抛异常
            raise
class TestAppArticle:
    # 1. 初始化
    def setup_class(self):
        # 1. 获取driver
        driver = GetDriver.get_app_driver()
        # 2. 获取统一入口类对象
        self.page_in = PageIn(driver)
        # 3. 调用登录成功方法
        self.page_in.page_get_PageAppLogin().page_app_login_success()
        # 4. 获取发布文章页面对象
        self.article = self.page_in.page_get_PageAppArticle()

    # 2. 结束
    def teardown_class(self):
        # 关闭driver
        GetDriver.quit_app_driver()

    # 3. 发布文章测试方法
    @pytest.mark.parametrize("click_text,title", read_yaml("app_article.yaml"))
    def test_app_article(self, click_text, title):
        try:
            # 调用发发布文章业务方法
            self.article.page_app_article(click_text, title)
        except Exception as e:
            # 日志
            log.error(e)
            # 截图
            self.article.base_get_img()
            # 抛异常
            raise
示例#27
0
 def setup_class(self):
     # 获取PageUserCenter对象
     self.page_user_center = PageIn.page_get_user_center()
     # 获取PageStockDetailPrice对象
     self.page_stock_detail_price = PageIn.page_get_stock_detail_price()
     # 进入搜索页
     self.page_stock_detail_price.page_click_search_index()
示例#28
0
class TestMisLogin:
    def setup(self):
        # 获取driver
        driver = GetWebDriver.get_web_driver(page.mis_url)
        # 获取mis页面
        self.mis = PageIn(driver).page_get_misLogin()

    def teardown(self):
        # 退出驱动
        GetWebDriver.quit_web_driver()

    @pytest.mark.parametrize("username,pwd,nickname",
                             read_yaml("mis_login.yaml"))
    def test_login(self, username, pwd, nickname):
        # 登陆业务方法
        self.mis.page_combination_login(username, pwd)
        # 断言
        try:
            assert nickname in self.mis.page_mis_nickname()
        except Exception as e:
            # 日志
            log.error(e)
            # 截图
            self.mis.base_get_img()
            raise
示例#29
0
 def setup_class(self):
     # 获取 PageAddress
     self.address = PageIn().page_get_pageaddress()
     # 获取PageLogin 并且登录成功
     PageIn().page_get_pagelogin().page_login_address()
     # 点击 地址管理
     self.address.page_click_manage()
示例#30
0
    def setup_class(self):

        # 1:获取driver
        driver = GetDriver.get_web_driver(page.url_mp)
        # 2:获取统一入口类获取类
        self.mp = PageIn(driver).page_get_PageMpLogin()
        pass