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
    def return_button_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(3).click()
            details = DetailsPage(driver)
            details.back_button().click()

            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_valid_user/" + screenshotName + ".png")

            raise
Ejemplo n.º 4
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
Ejemplo n.º 5
0
    def test_all_items_details_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)
            product.click_product_label(1)  #click label 1
            details = DetailsPage(driver)
            add_to_cart = details.check_single_add_to_cart(
            )  #click add_to_cart
            add_to_cart.click()
            general = GeneralPage(driver)
            general.drop_down_menu()
            general.pick_item_from_menu("Reset App State")
            general.delete_button_menu()
            add_to_cart_product = details.check_single_add_to_cart()

            #cart_qty = general.cart_qty()

            assert driver.current_url != "https://www.saucedemo.com/inventory.html"
            assert add_to_cart_product.text == "ADD TO CART"
            #assert cart_qty == 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/product_page/product_page_screentshots/product_page_performance_glitch/"
                + screenshotName + ".png")

            raise
Ejemplo n.º 6
0
    def test_default_display_click_product_label5(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)
            p_title = product.product_label(5)
            p_price = product.product_price(5)
            p_description = product.product_description()
            price = p_price.text
            p_description = p_description.text
            title = p_title.text
            title.click()
            details = DetailsPage(driver)
            title_label = details.check_single_label()
            price_label = details.check_single_price()
            description_label = details.check_single_description()
            img = details.check_single_img()

            assert price == price_label.text
            assert p_description == description_label.text
            assert title == title_label.text
            assert img.id_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/product_page/product_page_screentshots/product_page_performance_glitch/"
                + screenshotName + ".png")

            raise
Ejemplo n.º 7
0
    def test_order_placed_through_inventory_page(self, acc, pws):

        try:
            driver = self.driver
            driver.get(var_info.url_login)
            login = LoginPage(driver)
            login.enter_login_info(acc, pws)
            # login.enter_login_info(var_info.username_s, var_info.password_s)
            product = ProductPage(driver)
            product.click_add_to_cart(6)
            product.click_add_to_cart(3)
            product.click_add_to_cart(2)
            product.click_product_img(1)
            detail = DetailsPage(driver)
            detail.check_single_add_to_cart().click()
            general = GeneralPage(driver)
            general.cart_sign().click()
            cart_page = CartPage(driver)
            cart_page.cart_continue_shopping().click()
            product.click_add_to_cart(1)
            general.cart_sign().click()
            cart_page.cart_product_remove(1)
            cart_page.cart_checkout_button().click()
            client_info = ClientInfoPage(driver)
            client_info.input_first_name("Leyla")
            client_info.input_last_name("Hinderson")
            client_info.input_zipcode("78990")
            client_info.cancel_button().click()
            cart_page.cart_checkout_button().click()
            client_info.input_first_name("Leyla")
            client_info.input_last_name("Hinderson")
            client_info.input_zipcode("78990")
            client_info.continue_button().click()
            checkout_overview = CheckoutOverview(driver)
            checkout_overview.overview_cancel().click()
            general.cart_sign().click()
            cart_page.cart_checkout_button().click()
            client_info.input_first_name("Leyla")
            client_info.input_last_name("Hinderson")
            client_info.input_zipcode("78990")
            client_info.continue_button().click()
            checkout_overview = CheckoutOverview(driver)
            checkout_overview.overview_finish().click()
            success_img = checkout_overview.successfully_img()
            success_note = checkout_overview.successfully_placed_order()

            assert success_note == True
            assert success_img == True

        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/Regression_Reports/" +
                screenshotName + ".png")

            raise