def return_index(): """ return then index :return: """ # Determine whether there is BottomNavigation logger.info("Determine whether there is BottomNavigation") while not Element("BottomNavigation", "BottomNavigation").is_exist(): # key event:back logger.info("Key event:back") common.back() sleep(1) if Element("BottomNavigation", "BottomNavigation").is_exist(): break logger.info("Swipe down") common.my_swipe_to_down() sleep(1) if Element("BottomNavigation", "BottomNavigation").is_exist(): break # click the shop button Element("BottomNavigation", "SHOP").gets(0).click() wait_loading()
def testRecentlyViewed(self): try: email = loginGls[0][1] password = loginGls[0][2] bsnsCommon.login(email, password) bsnsCommon.wait_loading() if Element("Alert", "update_title").is_exist(): Element("Alert", "cancel").click() else: pass # go to daily new Element("daily_new", "daily_new").click() bsnsCommon.wait_loading() # view a goods Element("daily_new", "daily_new_goods").clicks(0) sleep(1) common.my_swipe_to_up() self.goods_name = Element("daily_new", "goods_name").get_attribute("text") # go to recently viewed common.back() sleep(1) bsnsCommon.go_to_me() bsnsCommon.wait_loading() Element("recently_viewed", "recently_viewed").click() # check result self.checkResult() except Exception as ex: self.logger.error(str(ex))
def check_result(self): # go to daily new while not Element("BottomNavigation", "BottomNavigation").is_exist(): common.back() else: Element("BottomNavigation", "SHOP").click() sleep(1) Element("daily_new", "daily_new").click() bsnsCommon.wait_loading() # find a goods Element("daily_new", "daily_new_goods").clicks(0) while Element("daily_new", "new_guide").does_exist(): Element("daily_new", "new_guide").click() else: pass # get goods currency value2 = Element("daily_new", "goods_currency").get_attribute("text") self.logger.info("Changed currency is:" + value2[0:3]) if value2[0:3] == self.value: self.assertEqual(1, 1) else: self.assertEqual(0, 1) while not Element("BottomNavigation", "BottomNavigation").is_exist(): common.back()
def return_index(): """ return then index :return: """ # Determine whether there is BottomNavigation logger.info("Determine whether there is BottomNavigation") while not Element("BottomNavigation", "BottomNavigation").is_exist(): # key event:back logger.info("Key event:back") common.back() sleep(1) if Element("BottomNavigation", "BottomNavigation").is_exist(): break logger.info("Swipe down") common.my_swipe_to_down() sleep(1) if Element("BottomNavigation", "BottomNavigation").is_exist(): break # click the shop button Element("BottomNavigation", "shop").click() wait_loading()
def input_coupon_code(coupon_code): """ input the coupon code :param coupon_code: :return: """ code_coupon = 0 if not coupon_code == "": # enter coupon_code if not Element("checkout", "coupon_code").is_exist(): common.my_swipe_to_up() else: Element("checkout", "coupon_code").click() wait_loading() Element("checkout", "coupon_freebie_input").send_key(coupon_code) sleep(1) Element("checkout", "coupon_freebie_save").click() if Element("Alert", "layout").is_exist(): message = Element("Alert", "message").get_attribute("text") if message == "success": logger.info("Using coupon code that is \'" + coupon_code + "\' successfully!") Element("Alert", "confirm").click() else: logger.info("The \'" + coupon_code + "\' coupon code can not be used.") Element("Alert", "confirm").click() common.back() code_coupon = 1 else: logger.info("Don't use coupon code.") return int(code_coupon)
def input_freebie(freebie): """ input the freebie :param freebie: :return: """ code_freebie = 0 if not freebie == "": # enter freebie if not Element("checkout", "freebie").is_exist(): common.my_swipe_to_up() else: Element("checkout", "freebie").click() wait_loading() Element("checkout", "coupon_freebie_input").send_key(freebie) sleep(1) Element("checkout", "coupon_freebie_save").click() if Element("Alert", "layout").is_exist(): message = Element("Alert", "message").get_attribute("text") if message == "success": logger.info("Using \'" + freebie + "\' points successfully!") Element("Alert", "confirm").click() else: logger.info("No points in account, using points failed.") Element("Alert", "confirm").click() common.back() code_freebie = 1 else: logger.info("Don't use shein points.") return int(code_freebie)
def check_result(self): if Element("shippinginfo", "shipping_info_title").is_exist(): value = Element("shippinginfo", "shipping_info_title").get_attribute("text") self.logger.info("The title of 'Shipping Info' is: " + value) if value == "Shipping Info": self.assertEqual(1, 1) else: self.assertEqual(0, 1) while not Element("BottomNavigation", "BottomNavigation").is_exist(): common.back() else: pass
def check_result(self): if Element("aboutus", "about_us_title").is_exist(): value = Element("aboutus", "about_us_title").get_attribute("text") self.logger.info("The title of 'About Us' is:" + value) if value == "About Us": self.assertEqual(1, 1) else: self.assertEqual(0, 1) while not Element("BottomNavigation", "BottomNavigation").is_exist(): common.back() else: pass
def check_result(self): if Element("returnpolicy", "return_policy_title").is_exist(): value = Element("returnpolicy", "return_policy_title").get_attribute("text") self.logger.info("The title of 'Return Policy' is:" + value) if value == "Return Policy": self.assertEqual(1, 1) else: self.assertEqual(0, 1) while not Element("BottomNavigation", "BottomNavigation").is_exist(): common.back() else: pass
def check_result(self): goods_list = Element("shopping_bag", "name").get_element_list() length2 = len(goods_list) self.logger.info("length : " + str(self.length) + "\n" + "length2 : " + str(length2)) if self.length == length2 + 1: self.assertEqual(1, 1) else: self.assertEqual(0, 1) while not Element("BottomNavigation", "BottomNavigation").is_exist(): common.back() else: pass
def check_result(self): sleep(1) # get cache size value = Element("account_setting", "cache_size").get_attribute("text") self.logger.info("After clear, cache size is:" + value) if value == "0.00M": self.assertEqual(1, 1) else: self.assertEqual(0, 1) while not Element("BottomNavigation", "BottomNavigation").is_exist(): common.back() else: pass
def checkRemoveResult(self): # go to My Wishlist common.back() bsnsCommon.wait_loading() common.my_swipe_to_up() goods = Element("wish_list", "wish_goods_name").get_element_list() if len(goods) > 0: for name in goods: name.get_attribute("text") goods_name = name if goods_name != self.goods_name: pass else: self.assertEqual(0, 1) break
def checkAddResult(self): # go to My Wishlist common.back() bsnsCommon.go_to_me() bsnsCommon.wait_loading() common.my_swipe_to_up() self.addResult = self.log.take_shot(self.driver, self.case_name) self.logger.info("Take shot, the picture path is:" + self.addResult) goods = Element("wish_list", "wish_goods_name").get_element_list() for name in goods: name.get_attribute("text") goods_name = name if goods_name == self.goods_name: self.assertEqual(1, 1) self.logger.info("Add goods successfully : OK")
def feedback(self, email, content): # go to feedback Element("account_setting", "feedback").click() sleep(1) # input feedback email Element("feedback", "feedback_email").send_key(email) # input feedback content Element("feedback", "feedback_message").send_key(content) if not Element("feedback", "submit").is_exist(): common.back() else: pass Element("feedback", "submit").click() while not Element("BottomNavigation", "BottomNavigation").is_exist(): common.back() else: pass
def removeWishlist(self): # go to My Wishlist common.back() bsnsCommon.go_to_me() bsnsCommon.wait_loading() common.my_swipe_to_up() # get remove goods name self.re_goods_name = Element( "wish_list", "wish_goods_name").gets(0).get_attribute("text") # find a goods Element("wish_list", "wish_goods_name").clicks(0) # remove goods from wish list while not Element("daily_new", "add_wishlist").is_exist(): common.my_swipe_to_up() else: Element("daily_new", "add_wishlist").click()
def testAddCart(self): try: self.logger.info("Enter the goods details") while not Element("Shop", "goods").is_exist(): myCommon.my_swipe_to_up() else: myCommon.my_swipe_to_up() Element("Shop", "goods").clicks(0) bsnsCommon.wait_loading() self.logger.info("Get the goods's name") self.goods_name = Element("title", "title").get_attribute("text") self.logger.info("Enter the shopping cart") Element("Shopping_cart", "shopping_cart").click() bsnsCommon.wait_loading() bsnsCommon.delete_goods_in_cart(self.goods_name) myCommon.back() bsnsCommon.wait_loading() goods_num = Element("Shopping_cart", "shopping_cart").get_attribute("text") self.logger.info("Add goods to cart") self.add_cart() self.check_result(goods_num) except Exception as ex: self.logger.error(str(ex))