Exemple #1
0
class TestPubAritcle:

    def setup_class(self):
        # 1.打开浏览器
        self.driver = DriverUtils.get_mp_driver()
        # 创建首页业务层的对象
        self.home_proxy = HomeProxy()
        # 创建发布文章业务层的对象
        self.pub_ari_proxy = PubAriProxy()
        # 创建登录页面的业务层对象

    def setup_method(self):
        self.driver.get("http://ttmp.research.itcast.cn/")

    # 定义测试方法
    @allure.severity(allure.severity_level.BLOCKER)
    @pytest.mark.parametrize(("ari_title", "ari_context", "ari_channel", "expect"),
                             get_case_data("./data/mp/test_pub_ari_data.json"))
    def test_pub_ari(self, ari_title, ari_context, ari_channel, expect):
        # 2.组织测试数据
        # config.PUB_ARI_TITLE = ari_title.format(time.strftime("%H%M%S"))
        config.PUB_ARITCAL_TITLE = ari_title.format(time.strftime("%H%M%S"))
        print("发布文章标题{}".format(config.PUB_ARITCAL_TITLE))
        # 3.执行测试步骤
        self.home_proxy.to_pub_ari_page()
        self.pub_ari_proxy.test_pub_aritcal(config.PUB_ARITCAL_TITLE, ari_context, ari_channel)
        # 截图
        get_allure_png(self.driver,"发布文章")
        # 4.结果断言
        assert is_element_exist(self.driver, expect)

    # 5.关闭浏览器
    def teardown_class(self):
        DriverUtils.quit_mp_driver()
class TestPubAritcle:
    def setup_class(self):
        # 打开新浏览器
        self.driver = DriverUtils.driver_get_mp()
        # 创建首页业务层对象
        self.home_proxy = HomeProxy()
        # 创建发布文章业务成的对象
        self.pub_ari_proxy = PubAriProxy()
        # 创建登录页面的业务层对象
        # self.login_proxy = LoginProxy()
    def setup_method(self):
        self.driver.get("http://ttmp.research.itcast.cn/")

    # 定义测试方法
    @pytest.mark.parametrize(
        ("title_ari", "context_ari", "channel_ari", "expect"),
        get_case_data("./data/mp/test_pub_ari_data.json"))
    def test_pub_ari(self, title_ari, context_ari, channel_ari, expect):
        # 组织测试数据
        config.PUB_ARITCAL_TITLE = title_ari.format(time.strftime("%H%M%S"))
        print(config.PUB_ARITCAL_TITLE)
        # 执行测试步骤
        self.home_proxy.to_pub_ari_page()
        self.pub_ari_proxy.test_pub_artcal(config.PUB_ARITCAL_TITLE,
                                           context_ari, channel_ari)
        get_allure_pne(self.driver, "发布文章")
        # 断言
        assert is_element_exist(self.driver, expect)

    def teardown_class(self):
        DriverUtils.driver_mp_quit()
Exemple #3
0
class TestPubArticle:
    # 2. 定义初始化方法
    def setup_class(self):
        # 2.1 实例化浏览器驱动对象
        self.driver = DriverUtils.get_mp_driver()
        # 2.2 实例化需调用的业务方法所在类的对象
        self.home_proxy = HomeProxy()
        self.pub_ari_proxy = PubAriProxy()

    def setup_method(self):
        self.driver.get("http://ttmp.research.itcast.cn")

    # 3. 定义测试类
    @allure.severity(allure.severity_level.BLOCKER)
    @pytest.mark.parametrize(("ari_title", "ari_context", "ari_channel_name", "expect"),
                             get_case_data("./data/mp/test_pub_ari_data.json"))
    def test_ari_publish(self, ari_title, ari_context, ari_channel_name, expect):
        # 3.1 定义测试数据
        # title = "test{}".format(time.strftime("%Y%m%d%H%M%S"))
        # context = "testtesttest测试测试测试"
        # channel_name = '测试开发'
        # 3.2 调用业务方法形成完整的业务
        config.PUB_ARITCAL_TITLE = ari_title.format(time.strftime("%Y%m%d%H%M%S"))
        time.sleep(3)
        self.home_proxy.to_pub_ari_page()
        time.sleep(3)
        self.pub_ari_proxy.test_publish_ari(config.PUB_ARITCAL_TITLE, ari_context, ari_channel_name)

        # 截图
        get_allure_png(self.driver, "发布文章")

        # 断言
        assert is_element_exist(self.driver, expect)
        # 点击内容管理
        # HomeHandle().click_context_tab()

    # 4. 关闭浏览器驱动对象
    def teardown_class(self):
        DriverUtils.quit_mp_driver()
Exemple #4
0
class TestMpLogin:
    # 定义初始化方法
    def setup_class(self):
        # 获取驱动的对象
        self.driver = DriverUtils.get_mp_driver()
        # 创建好所需要调用业务方法所在的类的对象
        self.login_proxy = LoginProxy()
        self.home_proxy = HomeProxy()
        self.pub_proxy = PubAriProxy()

    # 恢复到原点
    def setup_method(self):
        self.driver.get("http://ttmp.research.itcast.cn/")

    # 定义测试方法
    @pytest.mark.parametrize(
        ("ari_title", "ari_context", "ari_channel", "expect"),
        get_case_data("./data/mp/test_pub_data.json"))
    def test_mp_pub(self, ari_title, ari_context, ari_channel, expect):
        # 定义测试数据
        # username = "******"
        # code = "246810"
        # # 调用业务方法形成完整业务操作
        # self.login_proxy.test_mp_login(username, code)
        # # 断言
        # assert is_element_exist(self.driver, "江苏传智播客")
        config.PUB_ARITCAL_TITLE = ari_title.format(
            time.strftime("%Y%m%d%H%S%M"))
        self.home_proxy.to_pub_ari_page()
        self.pub_proxy.to_pub_ari_tab(config.PUB_ARITCAL_TITLE, ari_context,
                                      ari_channel)
        assert is_element_exist(self.driver, expect)
        # HomeHandle().click_context_tab()

    # 定义销毁的方法
    def teardown_class(self):
        DriverUtils.quit_mp_driver()