Exemple #1
0
 def test_shopping_add_cart_case(self):
     """商品添加购物车"""
     hm = HomePage(self.driver)
     hm.click(hm.classify_tab_loc)  #点击分类标签
     cifp = ClassifyPage(self.driver)  #实例化商品分类页
     cifp.click(cifp.cart_view_loc)  #点击搜索框
     cifp.send_keys(cifp.search_view_loc, "牛奶")  #输入牛奶
     cifp.click(cifp.suggest_contentt_loc)  #点击特仑苏牛奶
     gls = guess_like_shop(self.driver, "特仑苏纯牛奶",
                           cifp.result_recycler_loc)  #选择包含特仑苏纯牛奶的商品
     cifp.click(cifp.buy_now_loc, gls)  #点击
     cifp.click(cifp.cart_view_loc)  #跳转购物车页面
     spcp = ShoppingCartPage(self.driver)  #实例化购物车页面
     co = commodity_operating(self.driver,
                              spcp.shopping_cart_recycleview_loc, "特仑苏纯牛奶")
     self.assertEqual(co[5].text, cifp.text(cifp.buy_now_loc, gls))  #断言
     co[2].click()  #点击删除
     spcp.click(spcp.ensure_delete_the_goods_loc)
 def test_shopping_add_cart_case(self):
     """商品添加购物车"""
     sleep(5)
     hm = HomePage(self.driver)
     try:
         hm.click(hm.classify_tab_loc)  #点击分类标签
     except Exception:
         hm.click(hm.classify_tab_loc)  #点击分类标签
     cifp = ClassifyPage(self.driver)  #实例化商品分类页
     sleep(2)
     cifp.click(cifp.search_text_loc)  #点击搜索框
     sleep(2)
     cifp.send_keys(cifp.search_view_loc, "特仑苏纯牛奶")  #输入牛奶
     cifp.click(cifp.tv_search_loc)  #点击搜索
     sleep(3)
     cifp.click(cifp.milk_terunshu_loc)
     text1 = cifp.text(cifp.milk_terunshu_name_loc).strip("热销")
     cifp.click(cifp.cart_view_loc)  #跳转购物车页面
     spcp = ShoppingCartPage(self.driver)  #实例化购物车页面
     text2 = spcp.text(spcp.milk_name_loc)  #获取加入购物车商品名
     self.assertEqual(text1, text2)  #断言
     spcp.click(spcp.delete_the_goods_loc)  #点击删除
     spcp.click(spcp.ensure_delete_the_goods_loc)