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 test_reset_app_individual_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.click_add_to_cart(3)
            product.click_product_label(3)
            general = GeneralPage(driver)
            general.drop_down_menu()
            general.pick_item_from_menu("Reset App State")
            general.delete_button_menu()
            details = DetailsPage(driver)
            add_to_cart_product = details.check_single_add_to_cart()
            cart_qty = general.cart_qty()


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

            raise
Exemplo n.º 3
0
    def test_product_index_clickable_default_order(self):
        driver = self.driver
        driver.get(var_info.url_product)
        product = ProductPage(driver)
        order = product.name_display_order()
        product.click_product_label(2)
        id = var_info.id_a_to_z[2 - 1]

        print(driver.current_url)
        assert driver.current_url == "https://www.saucedemo.com/inventory-item.html?id=" + id
Exemplo n.º 4
0
    def test_product_lab_clickable_assigned_order(self):
        driver = self.driver
        driver.get(var_info.url_product)
        product = ProductPage(driver)
        product.pick_display_order("Price (high to low)")
        #assert order == "Price (low to high)"
        product.click_product_label(5)
        id = var_info.id_high_to_low[5 - 1]

        print(driver.current_url)
        assert driver.current_url == "https://www.saucedemo.com/inventory-item.html?id=" + id
    def test_click_title_check_return_button(self):
        driver = self.driver
        driver.get(var_info.url_product)
        product = ProductPage(driver)
        product.click_product_label("Sauce Labs Bolt T-Shirt")
        after_click = ProductAfterClickPage(driver)
        back = after_click.check_back_button()
        back.click()

        print(driver.current_url)
        assert driver.current_url == "https://www.saucedemo.com/inventory.html"
Exemplo n.º 6
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
    def test_add_to_cart(self):
        driver = self.driver
        driver.get(var_info.url_product)
        product = ProductPage(driver)
        product.click_product_label("Sauce Labs Onesie")

        after_click = ProductAfterClickPage(driver)
        add_to_cart = after_click.check_add_to_cart()
        add_to_cart.click()
        cart_sign = after_click.check_cart_sign()
        cart_qty = after_click.check_cart_qty()
        add_to_cart1 = after_click.check_add_to_cart()

        assert add_to_cart1.text == "REMOVE"
        assert cart_sign.is_displayed()
        assert cart_qty == "1"
    def test_add_items_checkout(self):
        driver = self.driver
        driver.delete_all_cookies()
        driver.get(var_info.url_product)
        product = ProductPage(driver)
        #driver.refresh()
        product.click_product_label("Sauce Labs Bike Light")
        after_click = ProductAfterClickPage(driver)
        add_to_cart1 = after_click.check_add_to_cart()
        add_to_cart1.click()
        cart_qty = after_click.check_cart_qty()
        # cart_qty.click()
        cart_sign = after_click.check_cart_sign()
        cart_sign.click()

        assert cart_qty == "1"
        assert driver.current_url == "https://www.saucedemo.com/cart.html"
    def test_add_items_back_and_forth(self):
        driver = self.driver
        driver.delete_all_cookies()
        driver.get(var_info.url_product)
        #driver.refresh()
        product = ProductPage(driver)
        product.click_product_label("Test.allTheThings() T-Shirt (Red)")
        after_click = ProductAfterClickPage(driver)
        driver.refresh()
        add_to_cart1 = after_click.check_add_to_cart()
        add_to_cart1.click()
        after_click.check_cart_qty()
        back = after_click.check_back_button()
        back.click()
        product.click_img(3)
        add_to_cart2 = after_click.check_add_to_cart()
        add_to_cart2.click()
        check_add_label = after_click.check_add_to_cart()
        cart_qty_total = after_click.check_cart_qty()

        assert cart_qty_total == "2"
        assert check_add_label.text == "REMOVE"
Exemplo n.º 10
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