from tools.get_driver import GetDriver from page.page_in import PageIn from log.get_logger import GetLogger import pytest from tools.read_yaml import read_yaml log = GetLogger.get_logger() 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']
import time from base.base_driver import init_driver from page.page import Page from log.get_logger import GetLogger log = GetLogger() class TestShopCart: def setup(self): self.driver = init_driver() self.page = Page(self.driver) def teardown(self): time.sleep(2) self.driver.quit() def test_add_shop_cart(self): # 首页,如果没有登录就登录 self.page.home.login_if_not(self.page) # 首页 - 分类 self.page.home.click_category() # 分类 - 商品列表 self.page.category.click_goods_list() # 商品列表 - 商品详情 self.page.goods_list.click_goods() # 记录一下 当前商品的标题 goods_title = self.page.goods_detail.get_goods_title_text() print(goods_title) # 商品详情 - 加入购物车