class TestOrder(unittest.TestCase): def setUp(self): # 实例化driver self.drver = GetDriver.get_driver() # 订单实例化 self.order = PageOrder(self.drver) # 调用登录依赖 PageLogin(self.drver).page_login_success() # 回到首页 self.order.base_index() def tearDown(self): # 关闭浏览器 self.drver.quit() # 调用组合业务方法,并断言 def test_order(self): self.order.page_order() msg = self.order.page_get_sumbit_result() print(msg) try: self.assertIn('提交成功', msg) print('订单提交成功') except Exception as e: log.error('错误内容为{}'.format(e)) self.order.base_get_image()
class TestOrder(unittest.TestCase): # setUp def setUp(self): # 获取driver self.driver = GetDriver().get_driver() # 调用登录PageLoge对象中,登录方法 PageLogin(self.driver).page_login_success() # 实例化PageOrder self.order = PageOrder(self.driver) sleep(3) # 回到首页 self.order.page_click_index() # tearDown def TearDown(self): # 关闭driver GetDriver().quit_dirver() def testorder(self): try: # 调用 下订单业务方法 self.order.page_order() # 断言 msg = self.order.page_get_order_result() print("msg:",msg) self.assertIn("提交成功",msg) except Exception as e: # 截图 self.order.base_get_image() # 日志 log.error(e)
class TestOrder(unittest.TestCase): # 初始化方法 def setUp(self): # 获取driver self.driver = GetDriver().get_driver() # 实例化 PageLogin 并调用登录 PageLogin(self.driver).page_login_success() # 获取PageOrder对象 self.order = PageOrder(self.driver) # 打开首页 self.order.base_click_index() # 结束方法 def tearDown(self): GetDriver().quit_driver() # 测试订单方法 def test_order(self): try: # 调用 订单业务流程 self.order.page_order() # 断言 self.assertIn("订单提交成功", self.order.page_get_order_result()) except Exception as e: # 日志、截图 log.error(e) self.order.base_get_image()