Exemplo n.º 1
0
class TestPubAritical:

    # 2.定义类级别初始化方法
    def setup_class(self):
        # 打开浏览器
        self.driver = DriverUtils.get_mp_driver()
        # 创建所需要页面的业务层的对象
        self.home_proxy = HomeProxy()
        self.pub_proxy = PubProxy()

    # 3.定义类级别销毁方法
    def teardown_class(self):
        DriverUtils.quit_mp_driver()

    # 4.定义测试方法
    def test_pub_aritical(self):
        # 5.组织测试数据
        title = BASE_ARITCAL_TITLE
        content = "1.面试官不太美丽 2.沟通不太顺畅"
        option = "数码产品"
        # 6.调用业务场的方法
        self.home_proxy.to_publish_page()
        self.pub_proxy.test_pub_aritcal(title, content, option)
        # 7.断言实际结果 "新增文章成功"
        is_suc = element_is_exist(driver=self.driver, text="新增文章成功")
        assert is_suc
Exemplo n.º 2
0
 def setup_class(self):
     # 1.打开浏览器
     self.driver = DriverUtils.get_mp_driver()
     # 创建首页业务层的对象
     self.home_proxy = HomeProxy()
     # 创建发布文章业务层的对象
     self.pub_ari_proxy = PubAriProxy()
Exemplo n.º 3
0
class TestPubArtical:

    # 2.定义初始化方法
    def setup_class(self):
        self.driver = DriverUtils.get_mp_driver()
        self.home_proxy = HomeProxy()
        self.pub_ar_proxy = PubArProxy()

    # 3.定义测试方法
    @pytest.mark.parametrize("ar_cont, ch_name",
                             build_data(BASE_PATH +
                                        "/data/test_pub_artical_data.json"))
    def test_pub_artical(self, ar_cont, ch_name):

        # 定义测试数据
        ar_title = PUB_ARTICAL_TITLE
        # ar_content = "我要去找工作"
        # option_name = "数码产品"
        logging.info("发布文章信息为文章标题={}, 文章内容={}, 文章频道={}".format(
            ar_title, ar_cont, ch_name))
        # 调用业务层方法
        logging.info("------>调用首页进入发布文章的业务方法")
        self.home_proxy.to_pub_pg()
        logging.info("------>调用发布文章页面发布文章的业务方法")
        # self.pub_ar_proxy.test_pup_artical(ar_title, ar_content, option_name)
        self.pub_ar_proxy.test_pup_artical(ar_title, ar_cont, ch_name)
        # 执行断言
        is_exists_element(self.driver, "新增文章成功")

    # 4.定义销毁方法
    def teardown_class(self):
        time.sleep(2)
        DriverUtils.quit_mp_driver()
Exemplo n.º 4
0
 def setup_class(self):
     # 打开新浏览器
     self.driver = DriverUtils.driver_get_mp()
     # 创建首页业务层对象
     self.home_proxy = HomeProxy()
     # 创建发布文章业务成的对象
     self.pub_ari_proxy = PubAriProxy()
class TestMpPubArt:

    # 2.定义初始化方法
    def setup_class(self):
        # 启动浏览器
        self.driver = DriverUtils.get_mp_driver()
        # 创建好对应要调用的业务层对象
        self.home_proxy = HomeProxy()
        self.pub_art_proxy = PubArtProxy()

    # 3.定义业务测试方法
    @pytest.mark.parametrize("art_content,channel_name",
                             build_data(BASE_PATH +
                                        "/data/test_pub_artical_data.json"))
    def test_mp_pub_art(self, art_content, channel_name):

        # a.定义测试数据
        art_title = PUB_ARTICAL_TITLE
        art_content = art_content
        option_name = channel_name

        logging.info("发布文章信息为:文章标题={},文章内容={},文章频道={}".format(
            art_title, art_content, channel_name))

        # b.调用业务层已经封装好的业务方法
        self.home_proxy.to_pub_artical_page()
        self.pub_art_proxy.test_pub_artical(art_title, art_content,
                                            option_name)
        # c 对测试结果进行断言
        assert is_exists_element(self.driver, "新增文章成功")

    # 4.定义销毁方法
    def teardown_class(self):
        time.sleep(2)
        DriverUtils.quit_mp_driver()
Exemplo n.º 6
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()
Exemplo n.º 7
0
class TestPublish:
    def setup_class(self):
        self.driver = utils.DriverUtil.get_mp_driver()
        self.home_proxy = HomeProxy()
        self.publish_proxy = PublishProxy()

    def setup(self):
        time.sleep(3)

    def teardown(self):
        utils.DriverUtil.get_mp_driver().get(
            "http://ttmp.research.itcast.cn/#/login")
        time.sleep(3)

    def test_click_to_home_list(self):
        # 测试数据
        title = "zbcceshi001"
        content = "吴迪阿三接电话"
        channel = "数据库"

        # 跳转文章发布页
        self.home_proxy.to_article_page()

        # 发布文章
        self.publish_proxy.publish_article(title, content, channel)
        logging.info("title={}, content={}, channel={}".format(
            title, content, channel))
        # 断言
        is_exist = utils.exist_text(self.driver, "新增文章成功")
        assert is_exist
Exemplo n.º 8
0
class TestPubAritical:

    # 定义类级别的初始化方法
    def setup_class(self):
        self.driver = DriverUtils.get_mp_driver()
        self.home_proxy = HomeProxy()
        self.pub_proxy = PubProxy()

    # 定义类级别销毁的方法
    def teardown_class(self):
        time.sleep(2)
        DriverUtils.quit_mp_driver()

    # 定义测试方法
    def test_pub_aritical(self):
        # 组织测试数据
        title = BASE_ARITCAL_TITLE
        content = "不用开风扇了,哈哈"
        option = "数码产品"
        # 调用业务层的方法
        self.home_proxy.to_publish_page()
        self.pub_proxy.test_pub_aritcal(title, content, option)
        time.sleep(3)

        # 断言实际结果
        is_suc = element_is_exist(driver=self.driver, text="新增文章成功")
        assert is_suc
Exemplo n.º 9
0
 def setup_class(self):
     # 获取驱动的对象
     self.driver = DriverUtils.get_mp_driver()
     # 创建好所需要调用业务方法所在的类的对象
     self.login_proxy = LoginProxy()
     self.home_proxy = HomeProxy()
     self.pub_proxy = PubAriProxy()
Exemplo n.º 10
0
class TestPublishArticle:
    def setup_class(self):
        self.driver = DriverUtils.get_mp_driver()
        self.pub_article_proxy = PubArticleProxy()
        self.home_proxy = HomeProxy()

    def teardown_class(self):
        DriverUtils.quit_mp_driver()

    # setup运行第二个用例是不会执行,需要用下面的方法
    def setup_method(self):
        DriverUtils.get_mp_driver().get("http://ttmp.research.itcast.cn/")

    @pytest.mark.parametrize(
        ("title", "content", "channel_name", "text"),
        build_data(
            r"F:\黑马\黑马就业班\UI自动化测试\课堂练习\day11\HM_TT_UI_TEST\data\mp_data\mp_publish_data.json"
        ))
    def test_publish_article(self, title, content, channel_name, text):
        config.PUB_ARTICLE_TITLE = title.format(time.strftime("%Y%m%d-%H%M%S"))
        print(config.PUB_ARTICLE_TITLE)
        self.home_proxy.home()
        self.pub_article_proxy.publish_article(title, content, channel_name)
        get_allure_screenshot(self.driver, "发布文章截图")
        assert is_element_exist(self.driver, text)
Exemplo n.º 11
0
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()
Exemplo n.º 12
0
    def setup_class(self):
        self.driver = DriverUtils.get_mp_driver()
        #登陆
        self.login = LoginProxy()
        self.login.test_login("13911111111", "246810")

        self.home_proxy = HomeProxy()
        self.pub_ari_proxy = PubAriProxy()
Exemplo n.º 13
0
class TestPubArticle:
    # 1.打开浏览器
    def setup_class(self):
        # 打开浏览器
        self.driver = DriverUtils.get_mp_driver()
        # 创建首页业务层的对象
        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(
        ("ari_title", "ari_context", "ari_channel", "expect"),
        get_case_data("./data/mp/test_pub_ari_atl.json"))
    def test_pub_ari(self, ari_title, ari_context, ari_channel, expect):
        # 2.组织测试数据
        config.PubArticleName = ari_title.format(time.strftime("%H%M%S"))
        # 3.执行测试步骤
        self.home_proxy.to_pub_air_tab()
        self.pub_ari_proxy.test_pub_aritcal(config.PubArticleName, ari_context,
                                            ari_channel)
        # 4.结果断言
        assert is_element_exist(self.driver, expect)
        # HomeHandle().cilck_context_tab()

    """
    不使用参数化的方法
    def test_pub_ari(self):
    # 2.组织测试数据
    ari_title = "BJ23_TESTNB_{}".format(time.strftime("%H%M%S"))
    ari_context = "我不想学测试,要秃头的"
    ari_channel = "软件测试"
    # # 执行登录
    # self.login_proxy.test_mp_login("13012345678", "246810")
    # 3.执行测试步骤
    self.home_proxy.to_pub_air_tab()
    self.pub_ari_proxy.test_pub_aritcal(ari_title, ari_context, ari_channel)
    # 4.结果断言
    assert is_element_exist(self.driver, "新增文章成功")
    不使用参数化的方法
    """

    # 5.关闭浏览器
    def teardown_class(self):
        DriverUtils.quit_mp_driver()
Exemplo n.º 14
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()
Exemplo n.º 15
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()
Exemplo n.º 16
0
class TestPubAritcal:
    # 2.定义初始化方法
    def setup_class(self):
        self.driver = DriverUtils.get_mp_driver()
        #登陆
        self.login = LoginProxy()
        self.login.test_login("13911111111", "246810")

        self.home_proxy = HomeProxy()
        self.pub_ari_proxy = PubAriProxy()

    # 3.定义测试方法
    @pytest.mark.parametrize(
        "ar_cont,ch_name",
        build_data(
            "C:\\Users\Administrator\Desktop\测试资料\项目实战\\autoToutiaoTest\data\\test_pub_artical_data.json"
        ))
    def test_pub_artical(self, ar_cont, ch_name):
        # 定义测试数据
        ari_title = PUB_ARTICAL_TITLE
        ari_content = ar_cont
        option_name = ch_name
        logging.info("发布文章信息为文章标题={},文章内容={},文章频道={}".format(
            ari_title, ar_cont, ch_name))
        # 调用业务层方法
        logging.info("----->调用首页进入发布文章的业务方法")
        self.home_proxy.to_pub_ar_pg()
        logging.info("----->调用发布文章页面发布文章的业务方法")
        self.pub_ari_proxy.test_pub_aritcal(ari_title, ari_content,
                                            option_name)
        # 执行断言
        assert is_exists_element(self.driver, "新增文章成功")

    # 4.定义销毁方法
    def teardown_class(self):
        time.sleep(2)
        DriverUtils.quit_mp_driver()
Exemplo n.º 17
0
class TestPubAritcal:
    # 2.定义初始化方法
    def setup_class(self):
        self.driver = DriverUtils.get_mp_driver()
        self.home_proxy = HomeProxy()
        self.pub_ari_proxy = PubAriProxy()

    # 3.定义测试方法
    def test_pub_artical(self):
        # 定义测试数据
        ari_title = "testCase_{}".format(time.strftime("%d%H%M%S"))
        ari_content = "我要出去找工作,找个好工作,月薪8W8,迎娶白富美!!!"
        option_name = "授课专用"
        # 调用业务层方法
        self.home_proxy.to_pub_ar_pg()
        self.pub_ari_proxy.test_pub_aritcal(ari_title, ari_content,
                                            option_name)
        # 执行断言
        assert is_exists_element(self.driver, "新增文章成功")

    # 4.定义销毁方法
    def teardown_class(self):
        time.sleep(2)
        DriverUtils.quit_mp_driver()
Exemplo n.º 18
0
 def setup_class(self):
     # 打开浏览器
     self.driver = DriverUtils.get_mp_driver()
     # 创建所需要页面的业务层的对象
     self.home_proxy = HomeProxy()
     self.pub_proxy = PubProxy()
Exemplo n.º 19
0
 def setup_class(self):
     self.driver = utils.DriverUtil.get_mp_driver()
     self.home_proxy = HomeProxy()
     self.publish_proxy = PublishProxy()
Exemplo n.º 20
0
 def setup_class(self):
     # 启动浏览器
     self.driver = DriverUtils.get_mp_driver()
     # 创建好对应要调用的业务层对象
     self.home_proxy = HomeProxy()
     self.pub_art_proxy = PubArtProxy()
Exemplo n.º 21
0
 def setup_class(self):
     self.driver = DriverUtils.get_mp_driver()
     self.home_proxy = HomeProxy()
     self.pub_ari_proxy = PubAriProxy()
Exemplo n.º 22
0
 def setup_class(self):
     # 2.1 实例化浏览器驱动对象
     self.driver = DriverUtils.get_mp_driver()
     # 2.2 实例化需调用的业务方法所在类的对象
     self.home_proxy = HomeProxy()
     self.pub_ari_proxy = PubAriProxy()