Beispiel #1
0
    def test_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_p, var_info.password_s)

            inventory = ProductPage(driver)
            inventory.click_add_to_cart(2)
            inventory.product_add_to_cart(4).click()
            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()

            outside = OutSideElement(driver)
            cart_qty = outside.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()

            print(item_total, tax, total)
            assert qty_item == 2
            assert cart_qty.text == "2"
            assert payment_info.is_displayed()
            assert delivery_info.is_displayed()
            assert item_total == "Item total: $59.980000000000004"
            assert tax == "Tax: $4.80"
            assert total == "Total: $64.78"
            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_problem_user/" + screenshotName + ".png")

            raise
    def test_cancel_purchase_before_complete(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_cancel()
            result.click()

            product2 = product.product_add_to_cart(2)
            product6 = product.product_add_to_cart(6)

            assert product2.text == "REMOVE"
            assert product6.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/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_cancel_order(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)

            inventory = ProductPage(driver)
            inventory.click_add_to_cart(2)
            inventory.product_add_to_cart(4).click()
            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()

            outside = OutSideElement(driver)
            cart_qty = outside.cart_qty()
            assert cart_qty.text == "2"

            overview = CheckoutOverview(driver)
            cancel_button = overview.overview_cancel()
            cancel_button.click()
            final_cart_qty = outside.cart_qty()

            assert final_cart_qty.text == "2"
            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/checkout_overview/checkout_overview_screenshots/checkout_overview_valid_user/"
                + screenshotName + ".png")

            raise
Beispiel #4
0
    def test_cancel_with_default(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_s, 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("Jill")
            info_page.input_last_name("Norstrom^")
            info_page.input_zipcode("77888")
            c_button = info_page.continue_button()
            c_button.click()
            overview = CheckoutOverview(driver)
            cancel = overview.overview_cancel()
            cancel.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/client_info/client_info_screenshots/client_info_page_valid_user/"
                + screenshotName + ".png")

            raise
    def test_cancel_with_default(self):
        try:
            driver = self.driver
            driver.get(var_info.url_checkout_step_one)
            info_page = ClientInfoPage(driver)
            info_page.input_first_name("Jill")
            info_page.input_last_name("Norstrom^")
            info_page.input_zipcode("77888")
            c_button = info_page.continue_button()
            c_button.click()
            overview = CheckoutOverview(driver)
            cancel = overview.overview_cancel()
            cancel.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/client_info/client_info_screenshots/client_info_page_performance_glitch/"
                + screenshotName + ".png")

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

        finally:
            print("Done")
Beispiel #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