def test_successful_order(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) finish_button = overview.overview_finish() finish_button.click() successful_order = overview.successfully_placed_order() successful_img = overview.successfully_img() final_cart_qty = outside.cart_qty() assert successful_order.is_displayed() assert successful_order == True assert successful_img == True 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_problem_user/" + screenshotName + ".png") raise except: print("There is an exception") raise finally: print("Done")
def test_purchase_successfully_with_products(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_finish() result.click() success = overview.successfully_img() general = GeneralPage(driver) qty = general.cart_qty() sign = general.cart_sign() assert success == True assert driver.current_url == "https://www.saucedemo.com/checkout-complete.html" assert qty == None assert sign.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/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_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_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_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_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")
def test_info_display_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) items = overview.total_product_in_cart() payment = overview.check_payment_all_info() delivery = overview.check_delivery_all_info() amount = overview.total_amount() assert items == None assert payment.is_displayed() == False assert delivery.is_displayed() == False assert isinstance(amount, list) == False 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_info_display_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) items = overview.total_product_in_cart() payment = overview.check_payment_all_info() delivery = overview.check_delivery_all_info() amount = overview.total_amount() assert items == None assert payment.is_displayed() == False assert delivery.is_displayed() == False assert isinstance(amount, list) == False 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_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(3) product.click_add_to_cart(5) general = GeneralPage(driver) general.cart_sign().click() cart_page = CartPage(driver) 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.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