def test_add_failure_error_object_marked_as_failure(): with slash.Session() as s: with s.get_started_context(): slash.add_failure('msg') [failure] = slash.context.result.get_failures() assert failure.is_failure()
def test_add_failure_error_object_marked_as_failure(): with slash.Session() as s: with s.get_started_context(): slash.add_failure('msg') [failure] = slash.context.result.get_failures() # pylint: disable=unbalanced-tuple-unpacking assert failure.is_failure()
def test_invalid_login(self): """ Test to validate Login with an invalid user, then use a valid user and logout from page """ driver = self.driver try: login = LoginPage(driver) # login with invalid_user login.enter_username(TestData.INVALID_USER) login.enter_password() login.click_login() assert self.driver.find_element_by_xpath(Locator.error_icon) slash.logger.info("Invalid user, please try again") # login with valid_user login.enter_username() login.enter_password() login.click_login() assert self.driver.find_element_by_id( Locator.menu_button).is_displayed() assert self.driver.find_element_by_class_name( Locator.product_label).is_displayed() login.scroll_page() # logout logout = LogoutPage(driver) logout.click_burger_button() logout.click_logout() assert login.bot_image slash.logger.info("Sucessfully logged out from {}".format( TestData.BASE_URL)) except Exception as exc: slash.add_failure("{}".format(exc))
def test_valid_logput(self): """ Test to validate logout """ driver = self.driver try: login = LoginPage(driver) # login with standard_user login.enter_username() login.enter_password() login.click_login() assert self.driver.find_element_by_id( Locator.menu_button).is_displayed() assert self.driver.find_element_by_class_name( Locator.product_label).is_displayed() login.scroll_page() # logout logout = LogoutPage(driver) logout.click_burger_button() logout.click_logout() assert login.bot_image slash.logger.info("Sucessfully logged out from {}".format( TestData.BASE_URL)) except Exception as exc: slash.add_failure("{}".format(exc))
def test_fill_users_info(self): """ Test to validate the user info page """ driver = self.driver try: login = LoginPage(driver) # login with standard_user login.enter_username() login.enter_password() login.click_login() assert self.driver.find_element_by_id( Locator.menu_button).is_displayed() assert self.driver.find_element_by_class_name( Locator.product_label).is_displayed() login.scroll_page() # select a the Backpack and add it to the shopping cart then check that that information is displayed home = HomePage(driver) home.add_backpack() # go to shopping cart and click checkout button home.click_cart_button() cart = ShoppingCartPage(driver) assert cart.find_cart_title().is_displayed() cart.click_checkout_button() # go to checkout page checkout = CheckoutPage(driver) assert checkout.locate_user_info_title().is_displayed() # go to checkout page and fill user's info then press continue button checkout.complete_user_info() checkout.click_continue_button() # go to overview page and check that title and payment info are displayed over = OverviewPage(driver) assert over.locate_overview_title().is_displayed() assert over.locate_payment_info().is_displayed() over.click_overview_cancel() # remove item from inventory page home = HomePage(driver) home.remove_backpack() # logout logout = LogoutPage(driver) logout.click_burger_button() logout.click_logout() assert login.bot_image slash.logger.info("Sucessfully logged out from {}".format( TestData.BASE_URL)) except Exception as exc: slash.add_failure("{}".format(exc))
def test_missing_info(self): """ Test to validate the integrity of users info """ driver = self.driver try: login = LoginPage(driver) # login with standard_user login.enter_username() login.enter_password() login.click_login() assert self.driver.find_element_by_id( Locator.menu_button).is_displayed() assert self.driver.find_element_by_class_name( Locator.product_label).is_displayed() login.scroll_page() # select a the Backpack and add it to the shopping cart then check that that information is displayed home = HomePage(driver) home.add_backpack() # go to shopping cart and click checkout button home.click_cart_button() cart = ShoppingCartPage(driver) assert cart.find_cart_title().is_displayed() cart.click_checkout_button() # go to checkout page checkout = CheckoutPage(driver) assert checkout.locate_user_info_title().is_displayed() # go to checkout page and enter First Name and Zip code, press continue and then wait for error checkout.incomplete_user_info() checkout.click_continue_button() error = CheckoutErrorPage(driver) assert error.check_last_name_error().is_displayed() # hit cancel button to go back to cart page checkout.click_cancel_button() # remove item from cart cart = ShoppingCartPage(driver) cart.remove_item_one() if not cart.get_items_cart_list().is_displayed(): slash.logger.info("Cart is empty") # logout logout = LogoutPage(driver) logout.click_burger_button() logout.click_logout() assert login.bot_image slash.logger.info("Sucessfully logged out from {}".format( TestData.BASE_URL)) except Exception as exc: slash.add_failure("{}".format(exc))
def test_single_item(self): """ Test to validate the addition of a multiple items to the shopping cart """ driver = self.driver try: login = LoginPage(driver) # login with standard_user login.enter_username() login.enter_password() login.click_login() assert self.driver.find_element_by_id( Locator.menu_button).is_displayed() assert self.driver.find_element_by_class_name( Locator.product_label).is_displayed() login.scroll_page() # select a the Backpack, Bike Light and Red T-shirt add them to the shopping cart # then check that that information is displayed items_to_add = [ Locator.back_pack, Locator.bike_light, Locator.red_tshirt ] for item in items_to_add: self.driver.find_element_by_xpath(item).click() sleep(TestData.DELAY) # go to shopping cart home = HomePage(driver) home.click_cart_button() cart = ShoppingCartPage(driver) assert cart.find_cart_title().is_displayed() assert cart.get_items_cart_qty().is_displayed() # remove item from cart items_to_remove = [ Locator.remove_third_element, Locator.remove_second_element, Locator.remove_first_element ] for stuff in items_to_remove: remove_item = self.driver.find_element_by_xpath(stuff) remove_item.click() sleep(TestData.DELAY) if not cart.get_items_cart_list().is_displayed(): slash.logger.info("Cart is empty") # logout logout = LogoutPage(driver) logout.click_burger_button() logout.click_logout() assert login.bot_image slash.logger.info("Sucessfully logged out from {}".format( TestData.BASE_URL)) except Exception as exc: slash.add_failure("{}".format(exc))
def test_valid_login(self): """ Test to validate the access to shopping cart page """ driver = self.driver try: login = LoginPage(driver) # login with standard_user login.enter_username() login.enter_password() login.click_login() assert self.driver.find_element_by_id( Locator.menu_button).is_displayed() assert self.driver.find_element_by_class_name( Locator.product_label).is_displayed() login.scroll_page() # select a the Backpack and add it to the shopping cart then check that that information is displayed home = HomePage(driver) home.add_backpack() # go to shopping cart home = HomePage(driver) home.click_cart_button() cart = ShoppingCartPage(driver) assert cart.find_cart_title().is_displayed() # remove item from cart cart = ShoppingCartPage(driver) cart.remove_item_one() if not self.driver.find_element_by_xpath( Locator.cart_qty).is_displayed(): slash.logger.info("Cart is empty") # logout logout = LogoutPage(driver) logout.click_burger_button() logout.click_logout() assert login.bot_image slash.logger.info("Sucessfully logged out from {}".format( TestData.BASE_URL)) except Exception as exc: slash.add_failure("{}".format(exc))
def before(self): """ Setup the browser and validate that we are in the login page """ self.driver = webdriver.Firefox( TestData.GECKO_PATH, service_log_path=TestData.GECKO_LOG_PATH) slash.logger.info("Run Started at:{}".format(datetime.datetime.now())) slash.logger.info("Chrome Environment Set Up") slash.logger.info("-" * 80) self.driver.implicitly_wait(20) self.driver.maximize_window() self.driver.get(TestData.BASE_URL) self.driver.set_page_load_timeout(30) try: # Validating page title with the expected. assert self.driver.title == TestData.EXPECTED_TITLE slash.logger.info("Login page loaded successfully") except Exception as exc: slash.add_failure("{}".format(exc))