class TestMpLogin: # 初始化方法 def setup_class(self): # 实例化浏览器驱动 self.driver = Driver.get_driver(page.mp_url) # 实例化自媒体对象 self.login_pm_page = PageMpLogin(self.driver) # 销毁资源方法 def teardown_class(self): Driver.quit_driver() # 登陆的测试方法 @pytest.mark.parametrize("info", ReadData().get_data("mp_login.yaml")) def test_login(self, info): # 调用自媒体的登陆业务方法 self.login_pm_page.page_mp_login(info[0], info[1]) try: # 获取登录后的昵称 nickname = self.login_pm_page.page_get_nickname() assert nickname == "test123" except Exception as e: # 1.截图,将图片写入测试报告 self.login_pm_page.base_get_image() # 2.将异常写入日志 log.error(e) # 3.抛出异常 raise
log.info("正在调用自媒体文章发布业务组合方法,文章名:{},文章内容:{},频道:{}".format(title,content,channel)) # 点击内容管理 self.page_click_content() # 点击发布文章 self.page_click_post_article() # 输入文章名称 self.page_input_title(title) # 输入文章内容 self.page_input_article_content(content) # 选择封面 self.page_check_cover() # 选择频道 self.page_check_channel(channel) # 点击发布 self.page_click_commit() if __name__ == '__main__': # 此处代码不可用,路径问题(log) driver = GetDriver().get_driver("http://ttmp.research.itcast.cn/#/login") page1 = PageMpLogin(driver) page1.page_mp_login("13812345678", "246810") print(page1.page_get_nickname()) time.sleep(2) page3 = PageMpArticle(driver) page3.page_publish_article("test111", "啦啦啦阿拉", "数据库") time.sleep(3) page3.page_get_commit_result() time.sleep(3) driver.quit()
def page_get_PageMpLogin(self): return PageMpLogin(self.driver)
def setup_class(self): # 实例化浏览器驱动 self.driver = Driver.get_driver(page.mp_url) # 实例化自媒体对象 self.login_pm_page = PageMpLogin(self.driver)