Exemplo n.º 1
0
    def testQty_minus(self):
        try:

            # Enter to the shopping cart
            self.logger.info("Enter to the shopping cart")
            Element("Shopping_cart", "shopping_cart").click()

            bsnsCommon.wait_loading()
            Element("Shopping_cart", "goods_num").send_keys(0, "0")

            # change qty_minus
            os.popen("adb shell input keyevent 61")
            sleep(1)
            os.popen("adb shell input keyevent 66")

            if Element("Alert", "layout").does_exist():

                value = Element("Alert", "message").get_attribute("text")

                self.assertEqual(value, self.message_min)

                sleep(1)
                Element("Alert", "confirm").click()
            # return the index
            bsnsCommon.return_index()

        except Exception as ex:
            self.logger.error(str(ex))
Exemplo n.º 2
0
def choose_shipping_payment_methods_in_checkout(shipping_method, payment_method):
    """
    choose method for shipping and payment
    :param shipping_method:
    :param payment_method:
    :return:
    """
    # choose shipping method
    shipping_methods = Element("checkout", "shopping_method").get_element_list()
    if shipping_methods is not None:
        methods = []
        for i in range(len(shipping_methods)):
            methods[i] = shipping_methods[i].get_attribute("text")
            if methods[i] is not None:
                if methods[i] == shipping_method:
                    logger.info("Choose the shipping method is:" + shipping_method)
                    Element("checkout", "shopping_method").gets(i).click()
    else:
        logger.info("The shipping method is none!")

    # choose payment method
    if not Element("checkout", "payment_method").is_exist():
        common.my_swipe_to_up()
    else:
        payment_methods = Element("checkout", "payment_method").get_element_list()
        if payment_methods is not None:
            payments = []
            for i in range(len(payment_methods)):
                payments[i] = payment_methods[i].get_attribute("text")
                if payments[i] == payment_method:
                    logger.info("Choose the payment method is:" + payment_method)
                    Element("checkout", "payment_method").gets(i).click()
        else:
            logger.info("The payment method is none!")
Exemplo n.º 3
0
    def testProfileAddressDelete(self):
        try:
            self.logger.info("Enter the profile")

            # find the bottom Navigation bar
            while not Element("BottomNavigation", "BottomNavigation").is_exist():
                sleep(1)
            else:
                # enter the profile
                Element("BottomNavigation", "profile").click()

            bsnsCommon.wait_loading()

            # first login
            user_name = loginCls[0][1]
            password = loginCls[0][2]

            bsnsCommon.login(user_name, password)

            bsnsCommon.wait_loading()

            # enter my address
            self.logger.info("Enter the my address")

            Element("profile", "profile_tv").clicks(3)

            self.addAddress()

            # delete address

            bsnsCommon.wait_loading()
        except Exception as ex:
            self.logger.error(str(ex))
    def testChangePassword(self):
        try:
            self.logger.info("Enter the profile")

            # find the bottom Navigation bar
            while not Element("BottomNavigation", "BottomNavigation").is_exist():
                sleep(1)
            else:
                # enter the profile
                Element("BottomNavigation", "profile").click()

            bsnsCommon.wait_loading()

            # first login
            user_name = loginCls[0][1]
            password = loginCls[0][2]

            bsnsCommon.login(user_name, password)

            bsnsCommon.wait_loading()

            # enter the account setting
            Element("profile", "profile_tv").clicks(0)
            bsnsCommon.wait_loading()

            # enter the change password
            Element("account_setting", "change_password").click()
            bsnsCommon.wait_loading()

            self.input_password(self.old_password, self.new_password, self.confirm_password)

            self.check_result()

        except Exception as ex:
            self.logger.error(str(ex))
Exemplo n.º 5
0
def login(email, password):
    """
    login app
    :return:
    """
    # cancel for update
    cancel_update()

    logger.info("Begin login the app")
    if Element("BottomNavigation", "BottomNavigation").is_exist():
        logger.debug("Current is already login, first logout")

        logout()

        logger.debug("Begin login")
    else:
        pass
        # Element("profile", "SignIn").click()
        # wait_loading()
    if Element("login", "fblogin").is_exist():
        login_input(email, password)

    else:
        Element("login", "loginText").click()
        login_input(email, password)

    logger.info("End login the app")
    def testDeleteAddress(self):
        try:
            email = loginGls[0][1]
            password = loginGls[0][2]
            # login app
            bsnsCommon.login(email, password)
            bsnsCommon.wait_loading()
            if Element("Alert", "update_title").is_exist():
                Element("Alert", "cancel").click()
            else:
                pass

            # go to 'ME'
            bsnsCommon.go_to_me()
            sleep(1)
            # go to add address page
            Element("address_management", "address_book").click()

            if Element("Address", "delete_address").is_exist():
                # delete address
                Element("Address", "delete_address").clicks(0)
                if Element("Alert", "layout").does_exist():
                    Element("Alert", "confirm").click()
            else:
                self.addAddress()
                # delete address
                Element("Address", "delete_address").clicks(0)
                if Element("Alert", "layout").does_exist():
                    Element("Alert", "confirm").click()

        except Exception as ex:
            self.logger.error(str(ex))
    def testLogin(self):
        """
        test login
        :return:
        """

        try:

            self.logger.info("Enter the profile")

            # find the bottom Navigation bar
            while not Element("BottomNavigation",
                              "BottomNavigation").is_exist():
                sleep(1)
            else:
                # enter the profile
                Element("BottomNavigation", "profile").click()

            bsnsCommon.wait_loading()

            # login the app
            bsnsCommon.login(self.email, self.password)

            # check the result
            self.check_result()

        except Exception as ex:
            self.logger.error(str(ex))
Exemplo n.º 8
0
    def check_result(self):
        """
        check result
        :return:
        """
        self.checkPoint = self.log.take_shot(self.driver, self.case_name)
        self.logger.info("Take shot, the picture path is:" + self.checkPoint)

        # login successfully
        if self.results == '1':
            bsnsCommon.wait_loading()
            if not Element("Alert", "layout").dose_exist():
                self.message = ""

                if Element("BottomNavigation",
                           "BottomNavigation").dose_exist():
                    value = ""
                    self.assertEqual(value, self.message)
                    bsnsCommon.logout()

        # login fail
        if self.results == '0':

            sleep(1)

            if Element("Alert", "layout").does_exist():
                value = Element("Alert", "message").get_attribute("text")

                self.assertEqual(value, self.message)

                sleep(1)
                Element("Alert", "confirm").click()
            else:
                pass
Exemplo n.º 9
0
    def check_result(self):

        self.CheckPoint = self.log.take_shot(self.driver, self.case_name)
        self.logger.info("Take shot, the picture path is " + self.CheckPoint)
        result = self.first_name + " " + self.last_name
        if self.results == "1":

            bsnsCommon.wait_loading()

            element_list = Element("address_management",
                                   "recipient").get_element_list()

            for i in range(len(element_list)):

                value = element_list[i].get_attribute("text")

                if result == value:

                    self.assertEqual(1, 1)

        if self.results == "0":
            sleep(1)

            if Element("Alert", "layout").does_exist():

                value = Element("Alert", "message").get_attribute("text")

                self.assertEqual(value, self.message)

                sleep(1)
                Element("Alert", "confirm").click()
Exemplo n.º 10
0
    def check_result(self, num):
        """
        check the result
        :return:
        """

        self.CheckPoint = self.log.take_shot(self.driver, self.case_name)
        self.logger.info("Take shot, the picture path is " + self.CheckPoint)

        if self.results == '1':

            goods_num = Element("Shopping_cart",
                                "shopping_cart").get_attribute("text")

            self.assertEqual(int(num) + 1, int(goods_num))

        if self.results == '0':

            sleep(1)

            if Element("Alert", "layout").does_exist():

                value = Element("Alert", "message").get_attribute("text")

                self.assertEqual(value, self.message)

                sleep(1)
                Element("Alert", "confirm").click()

                Element("add_cart", "cancel").click()
Exemplo n.º 11
0
def clear_cart():
    """
    clear the shopping cart
    :return:
    """
    logger.info("Clear the shopping cart")
    goods_list = []
    while Element("Shopping_cart", "goods_name").is_exist():
        logger.info("Get the goods name")
        element_list = Element("Shopping_cart", "goods_name").get_element_list()

        if element_list is not None:
            last_goods_name = element_list[-1].get_attribute("text")

            for i in range(len(element_list)):
                logger.info("Delete goods")

                Element("Shopping_cart", "delete_goods").clicks(i)

                Element("Alert", "confirm").click()

                wait_loading()
        if last_goods_name not in goods_list:

            logger.info("Goods is not end")

            logger.info("Swipe up, if not end")

            common.my_swipe_to_up()

            goods_list.append(last_goods_name)
        else:
            logger.info("Goods is end")
            break
    def testAddress(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 'ME'
            bsnsCommon.go_to_me()
            # go to address_book
            Element("address_management", "address_book").click()

            # add address
            Element("address_management", "add_address").click()
            bsnsCommon.input_address(self.first_name, self.last_name,
                                     self.phone, self.zip_code, self.address_1,
                                     self.address_2, self.city, self.country,
                                     self.state)

            # check result
            self.check_result()

        except Exception as ex:
            self.logger.error(str(ex))
Exemplo n.º 13
0
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()
Exemplo n.º 14
0
    def testReview(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("Enter the write review")
            while not Element("Good_details", "write_review").is_exist():
                myCommon.my_swipe_to_up()
            else:
                Element("Good_details", "write_review").click()

            bsnsCommon.wait_loading()

            self.logger.info("Write review")

            self.write_reviews()

            self.check_result()

        except Exception as ex:
            self.logger.error(str(ex))
    def testMyTickets(self):
        try:
            login_email = loginGls[0][1]
            login_pass = loginGls[0][2]
            bsnsCommon.login(login_email, login_pass)
            bsnsCommon.wait_loading()
            bsnsCommon.cancel_update()

            bsnsCommon.go_to_me()
            sleep(1)
            Element("my_tickets", "my_tickets").click()
            bsnsCommon.wait_loading()

            Element("my_tickets", "add_tickets").click()
            bsnsCommon.wait_loading()

            Element("my_tickets", "tickets_topic").click()
            bsnsCommon.wait_loading()

            self.inputTickets(self.first_name, self.last_name, self.email,
                              self.language, self.content)
            self.checkResult()

        except Exception as ex:
            self.logger.error(str(ex))
Exemplo n.º 16
0
    def check_result(self):
        """
        check the result
        :return:
        """

        self.CheckPoint = self.log.take_shot(self.driver, self.case_name)
        self.logger.info("Take shot, the picture path is " + self.CheckPoint)

        # login success
        if self.results == '1':

            bsnsCommon.wait_loading()

            value = Element("profile", "user").get_attribute("text")

            self.assertEqual(value, self.message)

        # login fail
        if self.results == '0':

            sleep(1)

            if Element("Alert", "layout").does_exist():

                value = Element("Alert", "message").get_attribute("text")

                self.assertEqual(value, self.message)

                sleep(1)
                Element("Alert", "confirm").click()
Exemplo n.º 17
0
    def write_reviews(self):

        if self.user_name != "default":
            Element("Review", "user_name").send_key(self.user_name)

        Element("Review", "content").send_key(self.content)

        Element("Review", "submit").click()
 def changeCurrency(self):
     # change currency
     Element("account_setting", "change_currency").click()
     sleep(1)
     Element("change_currency", "currency").clicks(1)
     self.value = Element("change_currency",
                          "currency").gets(1).get_attribute("text")
     self.logger.info("Currency is:" + self.value)
Exemplo n.º 19
0
    def clearCache(self):
        self.cache = Element("account_setting", "cache_size").get_attribute("text")
        self.logger.info("Cache size is:" + self.cache)
        Element("account_setting", "clear_cache").click()

        if Element("Alert", "clear_cache_sure").is_exist():
            Element("Alert", "clear_cache_sure").click()
        else:
            pass
Exemplo n.º 20
0
 def input_password(self, old_password, new_password, confirm_password):
     # input old password
     Element("change_password", "old_pass").send_key(old_password)
     # input new password
     Element("change_password", "new_pass").send_key(new_password)
     # input confirm password
     Element("change_password", "confirm_pass").send_key(confirm_password)
     # click submit button
     Element("change_password", "change_password").click()
Exemplo n.º 21
0
    def check_result(self):

        if Element("Alert", "layout").does_exist():

            value = Element("Alert", "message").get_attribute("text")

            self.assertEqual(value, self.message)

            sleep(1)
            Element("Alert", "confirm").click()
    def register(self):
        """
        register
        :return:
        """
        Element("register", "input").send_keys(0, self.email)
        Element("register", "input").send_keys(1, self.password)
        Element("register", "input").send_keys(2, self.confirm_password)

        Element("register", "register").click()
Exemplo n.º 23
0
def go_to_category():
    """
    go to category
    :return:
    """
    if Element("BottomNavigation", "BottomNavigation").is_exist():

        if Element("BottomNavigation", "CATEGORY").is_exist():
            bar_me = Element("BottomNavigation", "CATEGORY").gets(1)
            bar_me.click()
Exemplo n.º 24
0
def go_to_me():
    """
    go to consumer center
    :return:
    """
    if Element("BottomNavigation", "BottomNavigation").is_exist():

        if Element("BottomNavigation", "ME").is_exist():
            bar_me = Element("BottomNavigation", "ME").gets(4)
            bar_me.click()
Exemplo n.º 25
0
def enter_cart():
    """
    enter the shopping cart
    :return:
    """
    logger.info("Enter add cart page")
    if not Element("Good_details", "add").is_exist():
        common.my_swipe_to_up()
    else:
        Element("Good_details", "add").click()
    def checkResult(self):
        # successfully
        if self.result == 1:
            value = Element("Alert", "message").get_attribute("text")
            self.assertEqual(value, self.message)

        # fail
        if self.result == 0:
            value = Element("Alert", "message").get_attribute("text")
            self.assertEqual(value, self.message)
Exemplo n.º 27
0
    def addWishlist(self):
        # go to daily new
        Element("daily_new", "daily_new").click()
        bsnsCommon.wait_loading()

        # find a goods
        Element("daily_new", "daily_new_goods").clicks(0)
        # click new guide
        if Element("daily_new", "new_guide").is_exist():
            Element("daily_new", "new_guide").click()
        else:
            pass
        # get add goods name
        self.goods_name = Element("daily_new",
                                  "goods_name").get_attribute("text")
        # add goods to wish_list
        while not Element("daily_new", "add_wishlist").is_exist():
            common.my_swipe_to_up()
        else:
            Element("daily_new", "add_wishlist").click()
            if Element("Alert", "layout").does_exist():
                self.addResult = self.log.take_shot(self.driver,
                                                    self.case_name)
                self.logger.info("Take shot, the picture path is:" +
                                 self.addResult)
                Element("Alert", "confirm").click()
Exemplo n.º 28
0
def go_to_setting():
    """
    go to setting
    :return:
    """
    go_to_me()
    if not Element("loginOut", "setting").does_exist():
        return False
    else:
        Element("loginOut", "setting").click()

    return True
 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
Exemplo n.º 30
0
def wait_loading():
    """
    Waiting for the end of the page load
    :return:
    """
    # loading img
    while Element("Alert", "loading").is_exist():
        sleep(1)
    else:
        # time out
        if Element("Alert", "confirm").is_exist():
            Element("Alert", "confirm").click()