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_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_about_product_page(self):
        try:

            driver = self.driver
            # get url from var_info
            driver.get(var_info.url_login)

            # take driver into LoginPage
            login = LoginPage(driver)

            # get account and password
            login.enter_login_info(var_info.username_s, var_info.password_s)
            product = ProductPage(driver)
            general = GeneralPage(driver)
            product.product_logo()
            general.drop_down_menu()
            general.pick_item_from_menu("About")

            assert driver.current_url == "https://saucelabs.com/"

        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_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")
    def test_reset_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)
            overview = CheckoutOverview(driver)
            overview.overview_finish().click()
            general.drop_down_menu()
            general.pick_item_from_menu("Reset App State")
            general.delete_menu().click()
            final_cart_qty = outside.cart_qty()

            assert final_cart_qty == None
            assert driver.current_url == "https://www.saucedemo.com/checkout-complete.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
示例#6
0
    def test_problem_username_password(self):
        try:
            driver = self.driver
            #get url from var_info
            driver.get(var_info.url_login)

            #take driver into LoginPage
            login = LoginPage(driver)

            #get account and password
            login.enter_login_info(var_info.username_p, var_info.password_s)

            product = ProductPage(driver)

            #pick the option: "Logout"
            general = GeneralPage(driver)
            general.drop_down_menu()
            general.pick_item_from_menu("Logout")

            assert driver.current_url == "https://www.saucedemo.com/index.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
            #screenshotName = "screenshot" + cur_time

            allure.attach(driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            driver.get_screenshot_as_file(
                "/Users/yuchienhuang/Desktop/Swag_labs/Funtionality_Reports/login_out/login_out_screenhsots"
                + screenshotName + ".png")

            raise
        except:
            print("Sth wrong with username")
            raise
示例#7
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
    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