def test_009(self): """满减商品(满50减10),优惠券,红包,达豆,满折(满200打8折)活动""" # 满减商品 所有活动 #更改达豆数量 preConditionForTest().UpdateTestUserDadou() #清空购物车 preConditionForTest().clean_redis() self.openUrl('http://192.168.1.251:30011/login') time.sleep(3) if not getLoginStatus(self.driver.page_source): elementLocate(self.driver, ".//*[@id='uid']").sendKeysElementByXpath(self.store_username) elementLocate(self.driver, ".//*[@id='pwd']").sendKeysElementByXpath('123456') elementLocate(self.driver, ".//*[@id='login_submit']").clickElementByXpath() self.openUrl('http://192.168.1.251:30011/detail?gid={0}'.format(self.manJianGoodId)) elementLocate(self.driver, ".//div[2]/div/div[2]/div[1]/div/div[5]/div[2]/button").clickElementByXpath() elementLocate(self.driver, ".//div[2]/div/div[2]/div[1]/div/div[5]/div[2]/button").clickElementByXpath() elementLocate(self.driver, ".//div[2]/div/div[2]/div[1]/div/div[5]/div[2]/button").clickElementByXpath() elementLocate(self.driver, ".//*[@id='link_cart']").clickElementByXpath() elementLocate(self.driver, ".//*[@id='total']/div[2]/button").clickElementByXpath() # current_money=getFinalMoney(self.driver.page_source) # print u"购物车,物品价格100,3件,各活动满减后打8折" # print self._testMethodName,current_money # # TODO 需要加入金额断言 # if current_money != 207.0: # self.screenShot(getPath(self._testMethodName)) # self.assertTrue(current_money == 207.0) elementLocate(self.driver, ".//*[@id='cart_preview']/div[7]/div/div[1]").clickElementByXpath() elementLocate(self.driver, ".//*[@id='checkout_button']/button").clickElementByXpath() time.sleep(2) # 取消订单 time.sleep(2)
def test_006(self): """优惠券,达豆,满赠活动,满300赠,满折(满200打8折)""" #满赠活动 #更改达豆数量 preConditionForTest().UpdateTestUserDadou() #清空购物车 preConditionForTest().clean_redis() self.openUrl('http://192.168.1.251:30011/login') time.sleep(3) if not getLoginStatus(self.driver.page_source): elementLocate(self.driver, ".//*[@id='uid']").sendKeysElementByXpath( self.store_username) elementLocate(self.driver, ".//*[@id='pwd']").sendKeysElementByXpath('123456') elementLocate(self.driver, ".//*[@id='login_submit']").clickElementByXpath() self.openUrl('http://192.168.1.251:30011/detail?gid={0}'.format( self.manZengGoodId)) elementLocate(self.driver, ".//div[2]/div/div[2]/div[1]/div/div[5]/div[2]/button" ).clickElementByXpath() elementLocate(self.driver, ".//div[2]/div/div[2]/div[1]/div/div[5]/div[2]/button" ).clickElementByXpath() elementLocate(self.driver, ".//div[2]/div/div[2]/div[1]/div/div[5]/div[2]/button" ).clickElementByXpath() elementLocate(self.driver, ".//*[@id='link_cart']").clickElementByXpath() elementLocate(self.driver, ".//*[@id='total']/div[2]/button").clickElementByXpath() elementLocate(self.driver, ".//*[@id='cash_toggle_button']").clickElementByXpath() if elementLocate(self.driver, ".//*[@id='cash_amount']" ).findElementByXpath().text != '无可用红包': elementLocate(self.driver, ".//*[@id='cash_list']/div/div[1]/div/input" ).clickElementByXpath() self.driver.execute_script("window.scrollBy(0,300)") # getZGoodId,getZGoodIdCount=getZengId(self.driver.page_source) # print getZGoodId,getZGoodIdCount # current_money=getFinalMoney(self.driver.page_source) # print u"购物车,物品价格150,3件,赠物品后打8折" # print self._testMethodName,current_money # # TODO 需要加入金额断言 # if current_money != 345.0: # self.screenShot(getPath(self._testMethodName)) # self.assertTrue(current_money == 345.0) # self.assertTrue(self.ZGoodId==getZGoodId) # self.assertTrue(self.ZGoodIdCount==getZGoodIdCount) elementLocate(self.driver, ".//*[@id='cart_preview']/div[7]/div/div[1]" ).clickElementByXpath() elementLocate( self.driver, ".//*[@id='checkout_button']/button").clickElementByXpath() time.sleep(2) # 取消订单 time.sleep(2)
def test_005(self): """优惠券,红包,满减活动,满50减10""" #满减活动 #全局活动 #更改达豆数量 preConditionForTest().UpdateTestUserDadou() #清空购物车 preConditionForTest().clean_redis() self.openUrl('http://192.168.1.251:30011/login') time.sleep(3) if not getLoginStatus(self.driver.page_source): elementLocate(self.driver, ".//*[@id='uid']").sendKeysElementByXpath(self.store_username) elementLocate(self.driver, ".//*[@id='pwd']").sendKeysElementByXpath('123456') elementLocate(self.driver, ".//*[@id='login_submit']").clickElementByXpath() self.openUrl('http://192.168.1.251:30011/detail?gid={0}'.format(self.manJianGoodId)) elementLocate(self.driver,".//div[2]/div/div[2]/div[1]/div/div[5]/div[2]/button").clickElementByXpath() elementLocate(self.driver,".//*[@id='link_cart']").clickElementByXpath() elementLocate(self.driver,".//*[@id='total']/div[2]/button").clickElementByXpath() elementLocate(self.driver,".//*[@id='dadou_toggle_button']").clickElementByXpath() if elementLocate(self.driver,".//*[@id='dadou_no']").findElementByXpath().text!='0': elementLocate(self.driver,".//*[@id='dadou_check']").clickElementByXpath() # current_money=getFinalMoney(self.driver.page_source) # print u"购物车,物品价格100,1件,减10元" # print self._testMethodName,current_money # # TODO 需要加入金额断言 # if current_money != 75.0: # self.screenShot(getPath(self._testMethodName)) # self.assertTrue(current_money ==75.0) elementLocate(self.driver, ".//*[@id='cart_preview']/div[7]/div/div[1]").clickElementByXpath() elementLocate(self.driver, ".//*[@id='checkout_button']/button").clickElementByXpath() time.sleep(2) # 取消订单 time.sleep(2)
def test_004(self): """测试达豆,赠豆组合""" # 测试优惠券 #只允许达豆,赠豆 #更改达豆数量 preConditionForTest().UpdateTestUserDadou() #清空购物车 preConditionForTest().clean_redis() self.openUrl('http://192.168.1.251:30011/login') time.sleep(3) if not getLoginStatus(self.driver.page_source): elementLocate(self.driver, ".//*[@id='uid']").sendKeysElementByXpath( self.store_username) elementLocate(self.driver, ".//*[@id='pwd']").sendKeysElementByXpath('123456') elementLocate(self.driver, ".//*[@id='login_submit']").clickElementByXpath() self.openUrl('http://192.168.1.251:30011/detail?gid={0}'.format( self.zengDouGoodId)) elementLocate(self.driver, ".//div[2]/div/div[2]/div[1]/div/div[5]/div[2]/button" ).clickElementByXpath() elementLocate(self.driver, ".//*[@id='link_cart']").clickElementByXpath() elementLocate(self.driver, ".//*[@id='total']/div[2]/button").clickElementByXpath() elementLocate(self.driver, ".//*[@id='code_toggle_button']").clickElementByXpath() if elementLocate( self.driver, ".//*[@id='code_no']").findElementByXpath().text != '0': elementLocate(self.driver, ".//*[@id='code_list']/div[1]/div[1]/div/input" ).clickElementByXpath() self.driver.execute_script("window.scrollBy(0,700)") elementLocate(self.driver, ".//*[@id='cash_toggle_button']").clickElementByXpath() if elementLocate(self.driver, ".//*[@id='cash_amount']" ).findElementByXpath().text != '无可用红包': elementLocate(self.driver, ".//*[@id='cash_list']/div/div[1]/div/input" ).clickElementByXpath() self.driver.execute_script("window.scrollBy(0,500)") # current_money=getFinalMoney(self.driver.page_source) # print u"购物车,物品价格80,1件" # print self._testMethodName,current_money # # TODO 需要加入金额断言 # if current_money != 72.5: # self.screenShot(getPath(self._testMethodName)) # self.assertTrue(current_money == 72.5) elementLocate(self.driver, ".//*[@id='cart_preview']/div[7]/div/div[1]" ).clickElementByXpath() elementLocate( self.driver, ".//*[@id='checkout_button']/button").clickElementByXpath() time.sleep(2) # 取消订单 time.sleep(2)
def test_000(self): """数据准备""" #新建优惠券 preConditionForTest().TestMysqlCoupon() #新建红包 preConditionForTest().createNewRedGift() #取消客服所有订单 #preConditionForTest().cancleOrderFromSQL() print('新建优惠券5元,新建红包10元,发放达豆数量1000,取消客服所有订单')
def test_007(self): """第三方满赠商品活动(满250赠)""" #清空购物车 preConditionForTest().clean_redis() self.openUrl('http://192.168.1.251:30011/login') time.sleep(3) if not getLoginStatus(self.driver.page_source): elementLocate(self.driver, ".//*[@id='uid']").sendKeysElementByXpath( self.store_username) elementLocate(self.driver, ".//*[@id='pwd']").sendKeysElementByXpath('123456') elementLocate(self.driver, ".//*[@id='login_submit']").clickElementByXpath() self.openUrl('http://192.168.1.251:30011/activity/third?id=') if elementLocate(self.driver, ".//div[4]/div/div[2]/ul/div/div[1]/div/div[3]" ).findElementByXpath().text != '已领取': elementLocate(self.driver, ".//div[4]/div/div[2]/ul/div/div[1]/div/div[3]" ).clickElementByXpath() self.openUrl('http://192.168.1.251:30011/detail?gid={0}'.format( self.manZengThirdGoodId)) elementLocate(self.driver, ".//div[2]/div/div[2]/div[1]/div/div[6]/div[2]/button" ).clickElementByXpath() elementLocate(self.driver, ".//div[2]/div/div[2]/div[1]/div/div[6]/div[2]/button" ).clickElementByXpath() elementLocate(self.driver, ".//*[@id='link_cart']").clickElementByXpath() elementLocate(self.driver, ".//*[@id='total']/div[2]/button").clickElementByXpath() elementLocate(self.driver, ".//*[@id='cash_toggle_button']").clickElementByXpath() if elementLocate(self.driver, ".//*[@id='list_info']/div/div[2]" ).findElementByXpath().text != '0': elementLocate(self.driver, ".//*[@id='cash_list']/div/div[1]/div/input" ).clickElementByXpath() self.driver.execute_script("window.scrollBy(0,500)") # current_money=getFinalMoney(self.driver.page_source) # print u"购物车,黑卡商品价格100,3件" # print self._testMethodName,current_money # # TODO 需要加入金额断言 # if current_money != 298.0: # self.screenShot(getPath(self._testMethodName)) # self.assertTrue(current_money == 298.0) elementLocate(self.driver, ".//*[@id='cart_preview']/div[7]/div/div[1]" ).clickElementByXpath() elementLocate( self.driver, ".//*[@id='checkout_button']/button").clickElementByXpath() time.sleep(2)
def test_001(self): """尾货闪销活动(总价超过满折活动)""" #更改达豆数量 preConditionForTest().UpdateTestUserDadou() #清空购物车 preConditionForTest().clean_redis() self.openUrl('http://192.168.1.251:30011/login') time.sleep(3) if not getLoginStatus(self.driver.page_source): elementLocate(self.driver, ".//*[@id='uid']").sendKeysElementByXpath( self.store_username) elementLocate(self.driver, ".//*[@id='pwd']").sendKeysElementByXpath('123456') elementLocate(self.driver, ".//*[@id='login_submit']").clickElementByXpath() self.openUrl('http://192.168.1.251:30011/detail?gid={0}'.format( self.weihuoGoodId)) for s in range(7): elementLocate( self.driver, ".//div[2]/div/div[2]/div[1]/div/div[5]/div[2]/button" ).clickElementByXpath() elementLocate(self.driver, ".//*[@id='link_cart']").clickElementByXpath() elementLocate(self.driver, ".//*[@id='total']/div[2]/button").clickElementByXpath() elementLocate(self.driver, ".//*[@id='dadou_toggle_button']").clickElementByXpath() if elementLocate( self.driver, ".//*[@id='dadou_no']").findElementByXpath().text != '0': elementLocate(self.driver, ".//*[@id='dadou_check']").clickElementByXpath() # current_money=getFinalMoney(self.driver.page_source) # print u"购物车,尾货商品上架60,活动价格30,7件" # print self._testMethodName,current_money # # TODO 需要加入金额断言 # if current_money != 210.0: # self.screenShot(getPath(self._testMethodName)) # self.assertTrue(current_money == 210.0) elementLocate(self.driver, ".//*[@id='cart_preview']/div[7]/div/div[1]" ).clickElementByXpath() elementLocate( self.driver, ".//*[@id='checkout_button']/button").clickElementByXpath() elementLocate( self.driver, ".//div[2]/div[2]/div[3]/button[2]").clickElementByXpath() time.sleep(2) # 取消订单 time.sleep(2)
def test_006(self): """第三方满减商品活动第三梯度(满100减20,200减20,300减40),红包组合活动""" #清空购物车 preConditionForTest().clean_redis() self.openUrl('http://192.168.1.251:30011/login') time.sleep(3) if not getLoginStatus(self.driver.page_source): elementLocate(self.driver, ".//*[@id='uid']").sendKeysElementByXpath( self.store_username) elementLocate(self.driver, ".//*[@id='pwd']").sendKeysElementByXpath('123456') elementLocate(self.driver, ".//*[@id='login_submit']").clickElementByXpath() self.openUrl('http://192.168.1.251:30011/activity/third?id=') if elementLocate(self.driver, ".//div[4]/div/div[2]/ul/div/div[1]/div/div[3]" ).findElementByXpath().text != '已领取': elementLocate(self.driver, ".//div[4]/div/div[2]/ul/div/div[1]/div/div[3]" ).clickElementByXpath() self.openUrl('http://192.168.1.251:30011/detail?gid={0}'.format( self.manJianTDThirdGoodId)) elementLocate(self.driver, ".//div[2]/div/div[2]/div[1]/div/div[6]/div[2]/button" ).clickElementByXpath() elementLocate(self.driver, ".//div[2]/div/div[2]/div[1]/div/div[6]/div[2]/button" ).clickElementByXpath() elementLocate(self.driver, ".//div[2]/div/div[2]/div[1]/div/div[6]/div[2]/button" ).clickElementByXpath() elementLocate(self.driver, ".//*[@id='link_cart']").clickElementByXpath() elementLocate(self.driver, ".//*[@id='total']/div[2]/button").clickElementByXpath() # current_money=getFinalMoney(self.driver.page_source) # print u"购物车,价格100,多梯度满减 满100减10,满200减20,满300减40,3件" # print self._testMethodName,current_money # # TODO 需要加入金额断言 # if current_money != 252.0: # self.screenShot(getPath(self._testMethodName)) # self.assertTrue(current_money == 252.0) elementLocate(self.driver, ".//*[@id='cart_preview']/div[7]/div/div[1]" ).clickElementByXpath() elementLocate( self.driver, ".//*[@id='checkout_button']/button").clickElementByXpath() time.sleep(2)
def test_004(self): """黑卡商品,达豆活动,限时特价活动(原价120,现价100)(总价超过满折活动)""" #更改达豆数量 preConditionForTest().UpdateTestUserDadou() #清空购物车 preConditionForTest().clean_redis() self.openUrl('http://192.168.1.251:30011/login') time.sleep(3) if not getLoginStatus(self.driver.page_source): elementLocate(self.driver, ".//*[@id='uid']").sendKeysElementByXpath( self.store_username) elementLocate(self.driver, ".//*[@id='pwd']").sendKeysElementByXpath('123456') elementLocate(self.driver, ".//*[@id='login_submit']").clickElementByXpath() self.openUrl('http://192.168.1.251:30011/detail?gid={0}'.format( self.heikaTJGoodId)) elementLocate(self.driver, ".//div[2]/div/div[2]/div[1]/div/div[5]/div[2]/button" ).clickElementByXpath() elementLocate(self.driver, ".//div[2]/div/div[2]/div[1]/div/div[5]/div[2]/button" ).clickElementByXpath() elementLocate(self.driver, ".//div[2]/div/div[2]/div[1]/div/div[5]/div[2]/button" ).clickElementByXpath() elementLocate(self.driver, ".//*[@id='link_cart']").clickElementByXpath() elementLocate(self.driver, ".//*[@id='total']/div[2]/button").clickElementByXpath() # current_money=getFinalMoney(self.driver.page_source) # print u"购物车,黑卡商品价格100,3件" # print self._testMethodName,current_money # # TODO 需要加入金额断言 # if current_money != 290.0: # self.screenShot(getPath(self._testMethodName)) # self.assertTrue(current_money == 290.0) elementLocate(self.driver, ".//*[@id='cart_preview']/div[7]/div/div[1]" ).clickElementByXpath() elementLocate( self.driver, ".//*[@id='checkout_button']/button").clickElementByXpath() time.sleep(2) # 取消订单 time.sleep(2)
def test_000(self): """数据准备""" #新建优惠券 preConditionForTest().TestMysqlCoupon() #新建红包 preConditionForTest().createNewRedGift()