def reset_from_detail_page(self):
        try:
            driver = self.driver
            driver.get(var_info.url_login)
            login = LoginPage(driver)
            login.enter_login_info(var_info.username_s, var_info.password_s)
            product = ProductPage(driver)
            product.product_label(4).click()
            details = DetailsPage(driver)
            add_to_cart_label = details.check_single_add_to_cart()
            add_to_cart_label.click()
            general = GeneralPage(driver)
            general.drop_down_menu()
            general.pick_item_from_menu("Reset App State")
            general.delete_menu().click()
            add_label = details.check_single_add_to_cart()
            cart_qty = general.cart_qty()

            assert cart_qty == None
            assert add_label.text == "ADD TO CART"


        except AssertionError as error:
            print("AssertionError occurred")
            print(error)
            cur_time = datetime.datetime.now().strftime("%H-%M-%S_%d_%m_%Y")
            testName = utils.whoami()
            screenshotName = testName + "_" + cur_time

            allure.attach(self.driver.get_screenshot_as_png(), name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            self.driver.get_screenshot_as_file(
                "/Users/yuchienhuang/Desktop/Swag_labs/Funtionality_Reports/product_page/product_page_screentshots/product_page_valid_user/" + screenshotName + ".png")

            raise
    def test_individual_page_to_cart(self):
        try:
            driver = self.driver
            driver.get(var_info.url_login)
            login = LoginPage(driver)
            login.enter_login_info(var_info.username_p, var_info.password_s)
            product = ProductPage(driver)
            product.click_product_label(4)
            general = GeneralPage(driver)
            individual = DetailsPage(driver)
            individual.check_single_add_to_cart().click()
            general.cart_sign().click()
            cart = CartPage(driver)
            qty = general.cart_qty()
            items_display = cart.total_product_in_cart()

            assert items_display == 1
            assert qty.text == "1"
            assert driver.current_url == "https://www.saucedemo.com/cart.html"

        except AssertionError as error:
            print("AssertionError occurred")
            print(error)
            cur_time = datetime.datetime.now().strftime("%H-%M-%S_%d_%m_%Y")
            testName = utils.whoami()
            screenshotName = testName + "_" + cur_time

            allure.attach(self.driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            self.driver.get_screenshot_as_file(
                "/Users/yuchienhuang/Desktop/Swag_labs/Funtionality_Reports/cart_page/cart_page_screenshots/cart_page_problem_user/"
                + screenshotName + ".png")

            raise
예제 #3
0
    def test_remove_checkout(self):
        try:
            driver = self.driver
            driver.get(var_info.url_login)
            login = LoginPage(driver)
            login.enter_login_info(var_info.username_pe, var_info.password_s)
            product = ProductPage(driver)
            product.click_add_to_cart(2)
            product.click_add_to_cart(6)
            general = GeneralPage(driver)
            general.cart_sign().click()
            cart = CartPage(driver)
            cart.cart_product_remove(1)
            items_display = cart.total_product_in_cart()
            qty = general.cart_qty()

            assert items_display == 1
            assert qty.text == "1"

        except AssertionError as error:
            print("AssertionError occurred")
            print(error)
            cur_time = datetime.datetime.now().strftime("%H-%M-%S_%d_%m_%Y")
            testName = utils.whoami()
            screenshotName = testName + "_" + cur_time

            allure.attach(self.driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            self.driver.get_screenshot_as_file(
                "/Users/yuchienhuang/Desktop/Swag_labs/Funtionality_Reports/cart_page/cart_page_screenshots/cart_page_performance_glitch/"
                + screenshotName + ".png")

            raise
    def test_all_items_product_page(self):
        try:
            driver = self.driver
            driver.get(var_info.url_login)
            login = LoginPage(driver)
            login.enter_login_info(var_info.username_s, var_info.password_s)
            product = ProductPage(driver)
            general = GeneralPage(driver)
            product.product_logo()
            product.click_add_to_cart(1)
            product.click_add_to_cart(6)
            product.click_add_to_cart(3)
            product.click_add_to_cart(6)
            general.drop_down_menu()
            general.pick_item_from_menu("All Items")
            qty = general.cart_qty()

            assert driver.current_url == "https://www.saucedemo.com/inventory.html"
            assert qty.text == "2"


        except AssertionError as error:
            print("AssertionError occurred")
            print(error)
            cur_time = datetime.datetime.now().strftime("%H-%M-%S_%d_%m_%Y")
            testName = utils.whoami()
            screenshotName = testName + "_" + cur_time

            allure.attach(self.driver.get_screenshot_as_png(), name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            self.driver.get_screenshot_as_file(
                "/Users/yuchienhuang/Desktop/Swag_labs/Funtionality_Reports/product_page/product_page_screentshots/product_page_valid_user/" + screenshotName + ".png")

            raise
    def test_purchase_successfully_with_products(self):
        try:
            driver = self.driver
            driver.get(var_info.url_product)

            product = ProductPage(driver)
            product.click_add_to_cart(2)
            product.click_add_to_cart(6)
            general = GeneralPage(driver)
            sign = general.cart_sign()
            sign.click()

            cart = CartPage(driver)
            checkout_button = cart.cart_checkout_button()
            checkout_button.click()

            info_page = ClientInfoPage(driver)
            info_page.input_first_name("Jill")
            info_page.input_last_name("Maddison")
            info_page.input_zipcode("10990")
            c_button = info_page.continue_button()
            c_button.click()

            overview = CheckoutOverview(driver)
            result = overview.overview_finish()
            result.click()
            success = overview.successfully_img()

            general = GeneralPage(driver)
            qty = general.cart_qty()
            sign = general.cart_sign()

            assert success == True
            assert driver.current_url == "https://www.saucedemo.com/checkout-complete.html"
            assert qty == None
            assert sign.is_displayed()

        except AssertionError as error:
            print("AssertionError occurred")
            print(error)
            cur_time = datetime.datetime.now().strftime("%H-%M-%S_%d_%m_%Y")
            testName = utils.whoami()
            screenshotName = testName + "_" + cur_time

            allure.attach(self.driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            self.driver.get_screenshot_as_file(
                "/Users/yuchienhuang/Desktop/Swag_labs/Funtionality_Reports/client_info/client_info_screenshots/client_info_page_performance_glitch/"
                + screenshotName + ".png")

            raise
        except:
            print("There is an exception")
            raise

        finally:
            print("Done")
    def test_nothing_purchased_info_displayed(self):
        try:

            driver = self.driver
            driver.get(var_info.url_login)
            driver.refresh()
            loginpage = LoginPage(driver)
            loginpage.enter_login_info(var_info.username_s,
                                       var_info.password_s)

            general = GeneralPage(driver)
            general.cart_sign().click()

            cartpage = CartPage(driver)
            continue_button = cartpage.cart_checkout_button()
            continue_button.click()

            client_info = ClientInfoPage(driver)
            client_info.input_first_name("Erica")
            client_info.input_last_name("Liam")
            client_info.input_zipcode("78666")
            client_info.continue_button().click()

            cart_qty = general.cart_qty()
            overview = CheckoutOverview(driver)
            qty_item = overview.total_item()
            payment_info = overview.check_payment_all_info()
            delivery_info = overview.check_delivery_all_info()
            item_total, tax, total = overview.total_amount()
            finish_button = overview.overview_finish()
            cancel_button = overview.overview_cancel()

            #assert qty_item == 0
            #assert cart_qty == None
            assert payment_info.is_displayed() == False
            assert delivery_info.is_displayed() == False
            assert item_total == "Item total: $0"
            assert tax == "Tax: $0.00"
            assert total == "Total: $0.00"
            assert finish_button.is_displayed()
            assert cancel_button.is_displayed()

        except AssertionError as error:
            print("AssertionError occurred")
            print(error)
            cur_time = datetime.datetime.now().strftime("%H-%M-%S_%d_%m_%Y")
            testName = utils.whoami()
            screenshotName = testName + "_" + cur_time

            allure.attach(self.driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            self.driver.get_screenshot_as_file(
                "/Users/yuchienhuang/Desktop/Swag_labs/Funtionality_Reports/checkout_overview/checkout_overview_screenshots/checkout_overview_valid_user/"
                + screenshotName + ".png")

            raise
    def test_reset_with_items_overview(self):
        try:
            driver = self.driver
            driver.get(var_info.url_product)

            product = ProductPage(driver)
            product.click_add_to_cart(2)
            product.click_add_to_cart(6)
            general = GeneralPage(driver)
            sign = general.cart_sign()
            sign.click()

            cart = CartPage(driver)
            checkout_button = cart.cart_checkout_button()
            checkout_button.click()

            info_page = ClientInfoPage(driver)
            info_page.input_first_name("Jill")
            info_page.input_last_name("Maddison")
            info_page.input_zipcode("10990")
            c_button = info_page.continue_button()
            c_button.click()
            time.sleep(3)
            general.drop_down_menu()
            general.pick_item_from_menu("Reset App State")
            general.delete_menu().click()

            overview = CheckoutOverview(driver)
            total_product = overview.total_product_in_cart()

            qty = general.cart_qty()

            assert qty == None
            assert total_product == None

        except AssertionError as error:
            print("AssertionError occurred")
            print(error)
            cur_time = datetime.datetime.now().strftime("%H-%M-%S_%d_%m_%Y")
            testName = utils.whoami()
            screenshotName = testName + "_" + cur_time

            allure.attach(self.driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            self.driver.get_screenshot_as_file(
                "/Users/yuchienhuang/Desktop/Swag_labs/Funtionality_Reports/client_info/client_info_screenshots/client_info_page_performance_glitch/"
                + screenshotName + ".png")

            raise
        except:
            print("There is an exception")
            raise

        finally:
            print("Done")
예제 #8
0
    def test_cart_checkout(self):
        try:
            driver = self.driver
            driver.refresh()
            driver.get(var_info.url_login)
            login = LoginPage(driver)
            login.enter_login_info(var_info.username_p, var_info.password_s)
            product = ProductPage(driver)
            p_label1 = product.add_to_cart_label(1)
            p_label1.click()

            p_label2 = product.add_to_cart_label()
            p_label2.click()
            p_label3 = product.add_to_cart_label(3)
            p_label3.click()
            p_label4 = product.add_to_cart_label(4)
            p_label4.click()
            p_label5 = product.add_to_cart_label(5)
            p_label5.click()
            product.click_product_label(6)
            details = DetailsPage(driver)
            details.check_single_add_to_cart().click()

            general = GeneralPage(driver)
            general.cart_sign().click()
            cart_qty = general.cart_qty()

            assert driver.current_url == "https://www.saucedemo.com/cart.html"
            assert p_label1.text == "Remove"
            assert p_label3.text == "Remove"
            assert p_label4.text == "Remove"
            assert p_label5.text == "Remove"
            assert cart_qty.text == "6"

        except AssertionError as error:
            print("AssertionError occurred")
            print(error)
            cur_time = datetime.datetime.now().strftime("%H-%M-%S_%d_%m_%Y")
            testName = utils.whoami()
            screenshotName = testName + "_" + cur_time

            allure.attach(self.driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            self.driver.get_screenshot_as_file(
                "/Users/yuchienhuang/Desktop/Swag_labs/Funtionality_Reports/product_page/product_page_screentshots/product_page_performance_glitch/"
                + screenshotName + ".png")

            raise
예제 #9
0
    def test_products_add_to_cart_clickable_multiple_times(self):

        try:
            driver = self.driver
            #driver.refresh()
            driver.get(var_info.url_login)
            login = LoginPage(driver)
            login.enter_login_info(var_info.username_pe, var_info.password_s)
            product = ProductPage(driver)
            for i in range(1, 7):
                add_to_cart = product.product_add_to_cart(i)
                add_to_cart.click()

            a1 = product.product_add_to_cart(1)
            a1.click()
            a2 = product.product_add_to_cart(2)
            a2.click()
            a3 = product.product_add_to_cart(3)
            a3.click()
            a4 = product.product_add_to_cart(4)
            a4.click()
            a5 = product.product_add_to_cart(5)
            a5.click()
            a6 = product.product_add_to_cart(6)
            a6.click()

            general = GeneralPage(driver)
            qty = general.cart_qty()

            assert qty == None
            assert a4.text == "ADD TO CART"
            assert a5.text == "ADD TO CART"
            assert a6.text == "ADD TO CART"

        except AssertionError as error:
            print("AssertionError occurred")
            print(error)
            cur_time = datetime.datetime.now().strftime("%H-%M-%S_%d_%m_%Y")
            testName = utils.whoami()
            screenshotName = testName + "_" + cur_time

            allure.attach(self.driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            self.driver.get_screenshot_as_file(
                "/Users/yuchienhuang/Desktop/Swag_labs/Funtionality_Reports/product_page/product_page_screentshots/product_page_performance_glitch/"
                + screenshotName + ".png")

            raise
    def test_cancel_on_your_information(self):
        try:
            driver = self.driver
            driver.get(var_info.url_product)

            product = ProductPage(driver)
            product.click_add_to_cart(2)
            product.click_add_to_cart(6)
            general = GeneralPage(driver)
            sign = general.cart_sign()
            sign.click()

            cart = CartPage(driver)
            checkout_button = cart.cart_checkout_button()
            checkout_button.click()
            info_page = ClientInfoPage(driver)
            info_page.cancel_button().click()
            qty = general.cart_qty()
            total = cart.total_product_in_cart()

            assert driver.current_url == "https://www.saucedemo.com/cart.html"
            assert qty.text == "2"
            assert total == 2

        except AssertionError as error:
            print("AssertionError occurred")
            print(error)
            cur_time = datetime.datetime.now().strftime("%H-%M-%S_%d_%m_%Y")
            testName = utils.whoami()
            screenshotName = testName + "_" + cur_time

            allure.attach(self.driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            self.driver.get_screenshot_as_file(
                "/Users/yuchienhuang/Desktop/Swag_labs/Funtionality_Reports/client_info/client_info_screenshots/client_info_page_performance_glitch/"
                + screenshotName + ".png")

            raise
        except:
            print("There is an exception")
            raise

        finally:
            print("Done")
    def test_continue_shopping_button(self):

        try:
            driver = self.driver
            driver.get(var_info.url_login)
            login = LoginPage(driver)
            login.enter_login_info(var_info.username_p, var_info.password_s)
            product = ProductPage(driver)
            product.click_add_to_cart(2)
            product.click_add_to_cart(6)
            general = GeneralPage(driver)
            general.cart_sign().click()
            cart = CartPage(driver)
            shopping_button = cart.cart_continue_shopping()
            shopping_button.click()
            pro2 = product.product_add_to_cart(2)
            pro6 = product.product_add_to_cart(6)
            general = GeneralPage(driver)
            qty = general.cart_qty()

            assert pro2.text == "REMOVE"
            assert pro6.text == "REMOVE"
            assert driver.current_url == "https://www.saucedemo.com/inventory.html"
            assert qty.text == "2"

        except AssertionError as error:
            print("AssertionError occurred")
            print(error)
            cur_time = datetime.datetime.now().strftime("%H-%M-%S_%d_%m_%Y")
            testName = utils.whoami()
            screenshotName = testName + "_" + cur_time

            allure.attach(self.driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            self.driver.get_screenshot_as_file(
                "/Users/yuchienhuang/Desktop/Swag_labs/Funtionality_Reports/cart_page/cart_page_screenshots/cart_page_problem_user/"
                + screenshotName + ".png")

            raise
    def test_products_add_to_cart_clickable(self):
        try:
            driver = self.driver
            driver.refresh()
            driver.get(var_info.url_login)
            login = LoginPage(driver)
            login.enter_login_info(var_info.username_p, var_info.password_s)
            product = ProductPage(driver)
            for i in range(1, 7):
                add_to_cart = product.product_add_to_cart(i)
                add_to_cart.click()
            general = GeneralPage(driver)
            qty = general.cart_qty()

            a1 = product.product_add_to_cart(1)
            a2 = product.product_add_to_cart(2)
            a3 = product.product_add_to_cart(3)

            assert qty.is_displayed() == True
            assert qty.text == "6"
            assert a1.text == "REMOVE"
            assert a2.text == "REMOVE"
            assert a3.text == "REMOVE"

        except AssertionError as error:
            print("AssertionError occurred")
            print(error)
            cur_time = datetime.datetime.now().strftime("%H-%M-%S_%d_%m_%Y")
            testName = utils.whoami()
            screenshotName = testName + "_" + cur_time

            allure.attach(self.driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            self.driver.get_screenshot_as_file(
                "/Users/yuchienhuang/Desktop/Swag_labs/Funtionality_Reports/product_page/product_page_screentshots/product_page_problem_user/"
                + screenshotName + ".png")

            raise
예제 #13
0
    def test_reset_app_product_page(self):
        try:
            driver = self.driver
            driver.get(var_info.url_login)
            login = LoginPage(driver)
            login.enter_login_info(var_info.username_pe, var_info.password_s)
            product = ProductPage(driver)
            general = GeneralPage(driver)
            product.click_add_to_cart(2)
            product.click_add_to_cart(4)
            general.drop_down_menu()
            general.pick_item_from_menu("Reset App State")
            add_to_cart2 = product.add_to_cart_label(2)
            add_to_cart4 = product.add_to_cart_label(4)
            product.add_to_cart_label(4)
            general.delete_button_menu()
            cart_qty = general.cart_qty()

            assert cart_qty == None
            assert add_to_cart2.text == "ADD TO CART"
            assert add_to_cart4.text == "ADD TO CART"
            assert driver.current_url == "https://www.saucedemo.com/inventory.html"

        except AssertionError as error:
            print("AssertionError occurred")
            print(error)
            cur_time = datetime.datetime.now().strftime("%H-%M-%S_%d_%m_%Y")
            testName = utils.whoami()
            screenshotName = testName + "_" + cur_time

            allure.attach(self.driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            self.driver.get_screenshot_as_file(
                "/Users/yuchienhuang/Desktop/Swag_labs/Funtionality_Reports/product_page/product_page_screentshots/product_page_performance_glitch/"
                + screenshotName + ".png")

            raise
    def test_reset_button(self):
        try:
            driver = self.driver
            driver.get(var_info.url_login)
            login = LoginPage(driver)
            login.enter_login_info(var_info.username_p, var_info.password_s)
            product = ProductPage(driver)
            product.click_add_to_cart(2)
            product.click_add_to_cart(6)
            general = GeneralPage(driver)
            general.cart_sign().click()
            general.drop_down_menu()
            general.pick_item_from_menu("Reset App State")
            general.display_delete_button()
            cart = CartPage(driver)
            qty = general.cart_qty()
            items_display = cart.total_product_in_cart()

            assert qty == None
            assert items_display == None  #it should has nothing after hitting reset

        except AssertionError as error:
            print("AssertionError occurred")
            print(error)
            cur_time = datetime.datetime.now().strftime("%H-%M-%S_%d_%m_%Y")
            testName = utils.whoami()
            screenshotName = testName + "_" + cur_time

            allure.attach(self.driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            self.driver.get_screenshot_as_file(
                "/Users/yuchienhuang/Desktop/Swag_labs/Funtionality_Reports/cart_page/cart_page_screenshots/cart_page_problem_user/"
                + screenshotName + ".png")

            raise