def test_blank_info_cancel(self):
        try:
            driver = self.driver
            driver.get(var_info.url_checkout_step_one)
            info_page = ClientInfoPage(driver)

            info_page.input_first_name("")
            info_page.input_last_name("")
            info_page.input_zipcode("")
            info_page.cancel_button().click()

            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/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_invalid_info_with_cancel(self):
        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)

        inventory = ProductPage(driver)
        inventory.click_add_to_cart(2)
        inventory.label_add_to_cart("Sauce Labs Fleece Jacket")
        inventory.cart_sign().click()

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


        client_info = ClientInfoPage(driver)
        client_info.input_first_name("")
        client_info.input_last_name("")
        client_info.input_zipcode("")
        client_info.cancel_button().click()

        outside = OutSideElement(driver)
        checkout_button = cartpage.cart_checkout_button()
        checkout_button.click()
        cart_qty = outside.cart_qty()


        assert driver.current_url == "https://www.saucedemo.com/cart.html"
        assert cart_qty.text == "2"
Exemple #3
0
    def test_blank_info_cancel(self):
        try:
            driver = self.driver
            driver.get(var_info.url_login)
            login = LoginPage(driver)
            # get account and password
            login.enter_login_info(var_info.username_p, var_info.password_s)
            general = GeneralPage(driver)
            general.cart_sign().click()
            cartpage = CartPage(driver)
            time.sleep(3)
            cartpage.cart_checkout_button().click()
            info_page = ClientInfoPage(driver)

            info_page.input_first_name("")
            info_page.input_last_name("")
            info_page.input_zipcode("")
            info_page.cancel_button().click()

            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/client_info/client_info_screenshots/client_info_page_problem_user/" + 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_valid_info_cancel(self):
        try:
            driver = self.driver
            driver.get(var_info.url_login)
            login = LoginPage(driver)
            # get account and password
            login.enter_login_info(var_info.username_pe, var_info.password_s)
            general = GeneralPage(driver)
            general.cart_sign().click()
            cartpage = CartPage(driver)
            cartpage.cart_checkout_button().click()
            info_page = ClientInfoPage(driver)
            info_page.input_first_name("Jojo")
            info_page.input_last_name("Wang")
            info_page.input_zipcode("77759")
            cancel_button = info_page.cancel_button()
            cancel_button.click()

            cart_sign = info_page.info_cart_sign()
            cart_qty = info_page.info_cart_qty()

            assert driver.current_url == "https://www.saucedemo.com/cart.html"
            assert cart_sign.is_displayed()
            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/checkout_overview/checkout_overview_screenshots/checkout_overview_performance_glitch"
                + screenshotName + ".png")

            raise
Exemple #6
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