class TestSettlement: def setup_class(self): self.main = App().start().main() def setup(self): # 购物车数量是0 ,就切换到分类页面添加商品, if self.main.get_shopping_cart_count() == 0: self.main.goto_category().switch_category().add_item() # 然后在回到购物车页面 self.main.goto_shoping_cart() @pytest.mark.parametrize('data', yaml.safe_load(open(os.path.join(data_dir, 'data_settlement.yaml'), encoding='utf-8'))) def test_shopping_cart_to_settlement(self, data): self.settlement_page=self.main.goto_shoping_cart().goto_settlement_page() if self.settlement_page.is_addr(): self.settlement_page.add_pick_up_point(data['name'],data['phone']) if self.settlement_page.slide_to_bottom().is_open_item_but(): self.settlement_page.open_item_list() self.settlement_page.slide_to_bottom().goto_pay_page().back() def test_commodity_details_page_to_settlement(self): self.main.goto_home().slide_to_bottom().goto_commodity_details().goto_settlement_page()
class TestFirstPage: def setup_class(self): self.main = App().start().main() self.home = self.main.goto_home() def test_goto_category(self): res = self.home.goto_category().is_goto_category() self.main.goto_home() assert res == True def test_add_item_to_shop_cart(self): before_count = self.main.get_shopping_cart_count() res = self.home.slide_to_bottom().add_item_to_shop_cart() if res: self.home.choose_specifications_add_item_to_shop_cart() after_count = self.main.get_shopping_cart_count() assert before_count + 1 == after_count def test_goto_commodity_details(self): before_name = self.home.slide_to_bottom().get_first_item_name() after_name = self.home.goto_commodity_details().get_item_name() assert after_name in before_name