Beispiel #1
0
 def test_go_order_fill_case(self):
     """跳转到去结算"""
     hm = HomePage(self.driver)
     hm.click(hm.classify_tab_loc)  # 点击分类标签
     cifp = ClassifyPage(self.driver)  # 实例化商品分类页
     cifp.click(cifp.search_text_loc)  # 点击搜索框
     cifp.send_keys(cifp.search_view_loc, "牛奶")  # 输入牛奶
     cifp.click(cifp.suggest_contentt_loc)  # 点击特仑苏牛奶
     gls = guess_like_shop(self.driver, "特仑苏纯牛奶",
                           cifp.result_recycler_loc)  # 选择包含特仑苏纯牛奶的商品
     spcp = ShoppingCartPage(self.driver)  # 实例化购物车页面
     co = commodity_operating(self.driver,
                              spcp.shopping_cart_recycleview_loc, "特仑苏纯牛奶")
     cifp.click(cifp.buy_now_loc, gls)  # 点击
     cifp.click(cifp.cart_view_loc)  # 跳转购物车页面
     try:
         spcp.click(spcp.check_out_loc)  #点击去结算
     except Exception:
         spcp.click(spcp.close_btn_new_loc)  #如果有新人专享关闭新人专享
         spcp.click(spcp.check_out_loc)  # 点击去结算
     odfp = OrderFillPage(self.driver)  #实例化结算页面
     try:
         text = odfp.text(odfp.order_fill_title_loc)
     except Exception:
         odfp.click(odfp.redemption_give_up_loc)
         text = odfp.text(odfp.order_fill_title_loc)
     self.assertEqual(text.strip(), "订单填写")  #断言
     odfp.click(odfp.go_back_shopping_cart_loc)  #返回购物车
     co[0].click()  #选择要删除的商品
     spcp.click(spcp.delete_the_goods_loc)  #点击删除
     spcp.click(spcp.ensure_delete_the_goods_loc)  # 确认删除
Beispiel #2
0
 def test_delete_goods_case(self):
     """购物车删除商品"""
     hm = HomePage(self.driver)
     hm.click(hm.classify_tab_loc)  # 点击分类标签
     cifp = ClassifyPage(self.driver)  # 实例化商品分类页
     cifp.click(cifp.search_text_loc)  # 点击搜索框
     cifp.send_keys(cifp.search_view_loc, "牛奶")  # 输入牛奶
     cifp.click(cifp.suggest_contentt_loc)  # 点击特仑苏牛奶
     gls = guess_like_shop(self.driver, "特仑苏纯牛奶",
                           cifp.result_recycler_loc)  # 选择包含特仑苏纯牛奶的商品
     spcp = ShoppingCartPage(self.driver)  # 实例化购物车页面
     co = commodity_operating(self.driver,
                              spcp.shopping_cart_recycleview_loc, "特仑苏纯牛奶")
     cifp.click(cifp.buy_now_loc, gls)  # 点击
     cifp.click(cifp.cart_view_loc)  # 跳转购物车页面
     try:
         co[0].click()  # 选择要删除的商品
         spcp.click(spcp.delete_the_goods_loc)  # 点击删除
         spcp.click(spcp.ensure_delete_the_goods_loc)  # 确认删除
         cp = count_price(self.driver,
                          spcp.shopping_cart_recycleview_loc)  #获取商品名列表
     except Exception:
         spcp.click(spcp.close_btn_new_loc)  #如果有新人专享关闭新人专享
         co[0].click()  # 选择要删除的商品
         spcp.click(spcp.delete_the_goods_loc)  # 点击删除
         spcp.click(spcp.ensure_delete_the_goods_loc)  # 确认删除
         cp = count_price(self.driver, spcp.shopping_cart_recycleview_loc)
     self.assertNotIn(co[5].text, cp[1])  #断言
Beispiel #3
0
 def test_shopping_cart_subtract_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)  # 点击牛奶
     cifp.click(cifp.cart_view_loc)  # 跳转购物车页面
     spcp = ShoppingCartPage(self.driver)  # 实例化购物车页面
     spcp.click(spcp.add_shopping_loc)  # 点击增加
     number1 = int(spcp.text(spcp.count_shopping_loc))
     spcp.click(spcp.sub_shopping_loc)  #减少
     number2 = int(spcp.text(spcp.count_shopping_loc))
     self.assertTrue(number2 < number1)  # 断言
     spcp.click(spcp.delete_the_goods_loc)  # 点击删除
     spcp.click(spcp.ensure_delete_the_goods_loc)
Beispiel #4
0
 def test_return_shopping_cart_case(self):
     """从去凑单返回"""
     hm = HomePage(self.driver)
     hm.click(hm.classify_tab_loc)  # 点击分类标签
     cifp = ClassifyPage(self.driver)  # 实例化商品分类页
     cifp.click(cifp.search_text_loc)  # 点击搜索框
     cifp.send_keys(cifp.search_view_loc, "牛奶")  # 输入牛奶
     cifp.click(cifp.suggest_contentt_loc)  # 点击特仑苏牛奶
     gls = guess_like_shop(self.driver, "特仑苏纯牛奶",
                           cifp.result_recycler_loc)  # 选择包含特仑苏纯牛奶的商品
     spcp = ShoppingCartPage(self.driver)  # 实例化购物车页面
     cifp.click(cifp.buy_now_loc, gls)  # 点击
     cifp.click(cifp.cart_view_loc)  # 跳转购物车页面
     try:
         spcp.click(spcp.available_coupons_loc)  # 点击可用优惠券
     except Exception:
         spcp.click(spcp.close_btn_new_loc)  #如果有新人专享关闭新人专享
         spcp.click(spcp.available_coupons_loc)  # 点击可用优惠券
     co = commodity_operating(self.driver,
                              spcp.shopping_cart_recycleview_loc, "特仑苏纯牛奶")
     spcp.click(spcp.go_coudan_loc)  # 点击去凑单
     gcp = GoCoudanPage(self.driver)  #实例化去凑单页面
     gcp.click(gcp.return_shopping_cart_loc)  # 返回购物车
     self.assertEqual(
         spcp.text(spcp.shopping_cart_title_loc).strip(), "购物车")
     co[2].click()  # 点击删除
     spcp.click(spcp.ensure_delete_the_goods_loc)  # 确认删除
Beispiel #5
0
 def test_all_select_case(self):
     """购物车全选商品"""
     hm = HomePage(self.driver)
     hm.click(hm.classify_tab_loc)  # 点击分类标签
     cifp = ClassifyPage(self.driver)  # 实例化商品分类页
     cifp.click(cifp.search_text_loc)  # 点击搜索框
     cifp.send_keys(cifp.search_view_loc, "牛奶")  # 输入牛奶
     cifp.click(cifp.suggest_contentt_loc)  # 点击特仑苏牛奶
     gls = guess_like_shop(self.driver, "特仑苏纯牛奶",
                           cifp.result_recycler_loc)  # 选择包含特仑苏纯牛奶的商品
     spcp = ShoppingCartPage(self.driver)  # 实例化购物车页面
     cifp.click(cifp.buy_now_loc, gls)  # 点击
     cifp.click(cifp.cart_view_loc)  # 跳转购物车页面
     try:
         glsa = guess_like_shop_add(self.driver, 1,
                                    spcp.shopping_cart_recycleview_loc)
         glsa.click()  #选择猜你喜欢的商品
     except Exception:
         spcp.click(spcp.close_btn_new_loc)  # 如果有新人专享关闭新人专享
         glsa = guess_like_shop_add(self.driver, 1,
                                    spcp.shopping_cart_recycleview_loc)
         glsa.click()
     spcp.click(spcp.select_all_loc)  #取消全选
     spcp.click(spcp.select_all_loc)  #全选
     cp = count_price(self.driver,
                      spcp.shopping_cart_recycleview_loc)  #统计价格
     self.assertEqual(cp[0], float(spcp.text(spcp.all_price_loc)))  #断言
     spcp.click(spcp.delete_the_goods_loc)  #删除商品
     spcp.click(spcp.ensure_delete_the_goods_loc)  #确认删除
Beispiel #6
0
 def test_go_shopping_cart_case(self):
     """从首页去购物车"""
     hm = HomePage(self.driver)  #实例化商品首页
     hm.click(hm.classify_tab_loc)  # 点击分类标签
     hm.click(hm.cart_tab_loc)
     spcp = ShoppingCartPage(self.driver)  # 实例化购物车页面
     self.assertEqual(
         spcp.text(spcp.shopping_cart_title_loc).strip(), "购物车")
Beispiel #7
0
 def setUp(self) -> None:
     hp = HomePage(self.driver)
     hp.click(hp.adress_locator)
     sleep(1)
     hp.click(hp.city_locator)
     sleep(1)
     hp.click(hp.beijing_locator)
     sleep(1)
     hp.click(hp.return_locator)
     sleep(1)
     hp.click(hp.classify_locator)
     sleep(1)
Beispiel #8
0
 def test_go_shopping_cart_case(self):
     """从首页去购物车"""
     sleep(5)
     hm = HomePage(self.driver)  #实例化商品首页
     hm.click(hm.classify_tab_loc)  # 点击分类标签
     hm.click(hm.cart_tab_loc)
     spcp = ShoppingCartPage(self.driver)  # 实例化购物车页面
     try:
         text = spcp.text(spcp.shopping_cart_title_loc)
     except Exception:
         spcp.click(spcp.close_btn_new_loc)  #如果有新人专享关闭新人专享
         text = spcp.text(spcp.shopping_cart_title_loc)
     self.assertEqual(text.strip(), "购物车")
Beispiel #9
0
 def test_add_shopping_guess_you_like_case(self):
     """购物车猜你喜欢添加商品"""
     hm = HomePage(self.driver)  #实例化商品首页
     hm.click(hm.classify_tab_loc)  # 点击分类标签
     hm.click(hm.cart_tab_loc)
     spcp = ShoppingCartPage(self.driver)  # 实例化购物车页面
     glsa = guess_like_shop_add(self.driver, 1,
                                spcp.shopping_cart_recycleview_loc)
     glsa[0].click()  #添加
     co = commodity_operating(self.driver,
                              spcp.shopping_cart_recycleview_loc, glsa[1])
     self.assertEqual(glsa[1], co[5].text)
     co[2].click()  # 点击删除
     spcp.click(spcp.ensure_delete_the_goods_loc)  # 确认删除
Beispiel #10
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_search_order_by_adress(self):
     hp = HomePage(self.driver)
     sleep(1)
     hp.click(hp.order_qurey_locator)
     sleep(1)
     # 切换到main-frame
     bp = BasePage(self.driver)
     bp.switch_main_frame()
     sleep(1)
     # 输入地址
     oqp = OrderQueryPage(self.driver)
     hp.send_keys(oqp.input_adress_locator, self.adress_assert)
     # 点击搜索
     hp.click(oqp.click_search_locator)
     sleep(1)
     #断言
     op = OrderListPage(self.driver)
     text = hp.text(op.adress_locator)
     self.assertIn(self.adress_assert, text)
 def test_search_order_by_consignee_query(self):
     hp = HomePage(self.driver)
     sleep(1)
     hp.click(hp.order_qurey_locator)
     sleep(1)
     # 切换到main-frame
     bp = BasePage(self.driver)
     bp.switch_main_frame()
     sleep(1)
     # 输入收货人
     oqp = OrderQueryPage(self.driver)
     hp.send_keys(oqp.input_consignee_locator, self.consignee_name)
     # 点击搜索
     hp.click(oqp.click_search_locator)
     sleep(1)
     #断言
     op = OrderListPage(self.driver)
     text = hp.text(op.consignee_locator)
     self.assertIn(self.consignee_name, text)
 def test_search_order_by_phonenumber(self):
     # 进入到订单页面
     hp = HomePage(self.driver)
     sleep(1)
     hp.click(hp.order_qurey_locator)
     sleep(1)
     # 切换到main-frame
     bp = BasePage(self.driver)
     bp.switch_main_frame()
     sleep(1)
     # 输入收手机号码
     oqp = OrderQueryPage(self.driver)
     hp.send_keys(oqp.input_phonenumber_locator, self.phonenumber)
     # 点击搜索
     hp.click(oqp.click_search_locator)
     sleep(1)
     #断言
     op = OrderListPage(self.driver)
     text = hp.text(op.phonenumber_locator)
     self.assertIn(self.phonenumber, text)
 def test_search_order_by_area(self):
     hp = HomePage(self.driver)
     sleep(1)
     hp.click(hp.order_qurey_locator)
     sleep(1)
     # 切换到main-frame
     bp = BasePage(self.driver)
     bp.switch_main_frame()
     sleep(1)
     # 选择地区
     oqp = OrderQueryPage(self.driver)
     hp.select(oqp.coutry_select_locator).select_by_index(1)
     sleep(1)
     hp.select(oqp.province_select_locator).select_by_index(1)
     sleep(1)
     hp.select(oqp.city_select_locator).select_by_index(1)
     sleep(1)
     hp.select(oqp.district_select_locator).select_by_index(1)
     sleep(1)
     # 点击搜索
     hp.click(oqp.click_search_locator)
     sleep(1)
     #断言
     hp.click(self.lookover_locator)
     sleep(1)
     text = hp.text(self.assert_adress_locator)
     self.assertIn(self.assert_adress, text)
Beispiel #15
0
 def test_shopping_cart_subtract_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)  # 选择包含特仑苏纯牛奶的商品
     spcp = ShoppingCartPage(self.driver)  # 实例化购物车页面
     co = commodity_operating(self.driver,
                              spcp.shopping_cart_recycleview_loc, "特仑苏纯牛奶")
     cifp.click(cifp.buy_now_loc, gls)  # 点击
     cifp.click(cifp.cart_view_loc)  #跳转购物车页面
     co[1].click()  # 点击增加
     number1 = co[4].text()
     co[2].click()
     number2 = co[4].text()
     self.assertTrue(number2 < number1)  # 断言
     co[2].click()  # 点击删除
     spcp.click(spcp.ensure_delete_the_goods_loc)  # 确认删除
Beispiel #16
0
 def test_go_coudan_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)  # 选择包含特仑苏纯牛奶的商品
     spcp = ShoppingCartPage(self.driver)  # 实例化购物车页面
     co = commodity_operating(self.driver,
                              spcp.shopping_cart_recycleview_loc, "特仑苏纯牛奶")
     cifp.click(cifp.buy_now_loc, gls)  # 点击
     cifp.click(cifp.cart_view_loc)  #跳转购物车页面
     spcp.click(spcp.available_coupons_loc)  #点击可用优惠券
     spcp.click(spcp.go_coudan_loc)  #点击去凑单
     gcp = GoCoudanPage(self.driver)
     self.assertEqual(gcp.text(gcp.go_coudan_title_loc).strip(), "凑单有优惠")
     gcp.click(gcp.return_shopping_cart_loc)  #返回购物车
     co[2].click()  # 点击删除
     spcp.click(spcp.ensure_delete_the_goods_loc)  # 确认删除
Beispiel #17
0
 def test_print_order(self):
     #进入订单页面
     hp = HomePage(self.driver)
     sleep(1)
     hp.click(hp.orderlist_locator)
     sleep(1)
     #切换到main-frame
     bp = BasePage(self.driver)
     bp.switch_main_frame()
     sleep(1)
     #选中订单
     op = OrderListPage(self.driver)
     op.click(op.click_order_locator)
     sleep(1)
     #点击打印订单
     op.click(op.print_locator)
     sleep(1)
     #切换到新开窗口订单打印界面
     bp.switch_window()
     #断言
     pp = PrintPage(self.driver)
     text = bp.text(pp.printorder_word_locator)
     self.assertEqual(self.assert_word, text)
 def test_search_order_by_consignee(self):
     #进入到订单页面
     hp = HomePage(self.driver)
     sleep(1)
     hp.click(hp.orderlist_locator)
     sleep(1)
     # 切换到main-frame
     bp = BasePage(self.driver)
     bp.switch_main_frame()
     sleep(1)
     #输入收货人
     op = OrderListPage(self.driver)
     op.send_keys(op.input_consignee_locator, self.consignee_name)
     #订单状态选择最上面一项
     select = op.select(op.select_status_locator)
     select.select_by_value('-1')
     sleep(1)
     #点击搜索
     op.click(op.search_locator)
     sleep(1)
     #断言
     get_consignee_name = op.text(op.consignee_locator)
     self.assertEqual(self.consignee_name, get_consignee_name)
Beispiel #19
0
 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)
Beispiel #20
0
 def test_add_adress_case(self):
     """添加地址"""
     name = "leo"
     tel = "18227589708"
     city = "成都市"
     address = "锦江区东方广场c座"
     doorplate = "7楼"
     hm = HomePage(self.driver)
     hm.click(hm.classify_tab_loc)  # 点击分类标签
     cifp = ClassifyPage(self.driver)  # 实例化商品分类页
     cifp.click(cifp.search_text_loc)  # 点击搜索框
     cifp.send_keys(cifp.search_view_loc, "牛奶")  # 输入牛奶
     cifp.click(cifp.suggest_contentt_loc)  # 点击特仑苏牛奶
     gls = guess_like_shop(self.driver, "特仑苏纯牛奶",
                           cifp.result_recycler_loc)  # 选择包含特仑苏纯牛奶的商品
     spcp = ShoppingCartPage(self.driver)  # 实例化购物车页面
     cifp.click(cifp.buy_now_loc, gls)  # 点击需要买的商品
     cifp.click(cifp.cart_view_loc)  # 跳转购物车页面
     try:
         spcp.click(spcp.check_out_loc)  # 点击去结算
     except Exception:
         spcp.click(spcp.close_btn_new_loc)  # 如果有新人专享关闭新人专享
         spcp.click(spcp.check_out_loc)  # 点击去结算
     odfp = OrderFillPage(self.driver)  #实例化结算页面
     try:
         odfp.click(odfp.address_lable_loc)  #点击去填写地址
     except Exception:
         odfp.click(odfp.redemption_give_up_loc)  #放弃换购
         odfp.click(odfp.address_lable_loc)  #点击去填写地址
     aap = AdressAddPage(self.driver)  #实例化填写地址页面
     aap.click(aap.edit_address_receiver_loc)
     aap.send_keys(aap.edit_address_receiver_loc, name)  #填写收件人姓名
     aap.click(aap.sex_sir_loc)  #性别选男
     aap.click(aap.edit_address_tel_loc)
     aap.send_keys(aap.edit_address_tel_loc, tel)  #填写电话号码
     aap.click(aap.edit_detail_address_loc)  #点击填写地址
     nadp = NewAddAdressPage(self.driver)  #实例化新加地址页面
     nadp.click(nadp.entrance_choose_city_loc)  #点击搜索框旁边城市
     cocp = ChooseCityPage(self.driver)  #实例化选择城市
     cocp.click(cocp.search_address_input_city_loc)  #点击一下城市输入框
     cocp.send_keys(cocp.search_address_input_city_loc, city)  #输入成都市
     cocp.click(cocp.click_input_city_loc)  #点击输入的城市成都市
     nadp.click(nadp.search_address_input_loc)
     nadp.send_keys(nadp.search_address_input_loc, address)  #输入锦江区东方广场c座
     nadp.click(nadp.choose_input_address_loc)  #点击输入的地址
     aap.click(aap.edit_doorplate_loc)
     aap.send_keys(aap.edit_doorplate_loc, doorplate)  #输入门牌号
     aap.click(aap.home_address_tags_loc)  #选择家标签
     aap.click(aap.save_address_loc)  #保存地址
     self.assertEqual(
         odfp.text(odfp.address_detail_loc).strip(),
         address + doorplate)  #断言
     odfp.click(odfp.go_back_shopping_cart_loc)  #返回购物车
     spcp.click(spcp.delete_the_goods_loc)  #点击删除
     spcp.click(spcp.ensure_delete_the_goods_loc)  #确认删除
     spcp.click(spcp.mine_tab_loc)  #去我的
     mp = MinePage(self.driver)  #实例化我的页面
     mp.to_up()  #向上滑
     mp.click(mp.shipping_address_loc)  #点击收货地址
     esap = EditShippingAddressPage(self.driver)  #实例化编辑地址
     esap.click(esap.edit_shipping_address_loc)  #点击编辑
     esap.click(esap.delete_address_loc)  #点击删除