def test_login_problem_user(self): login_page = LoginPage(self.driver) account = Account('problem_user', Data.PASSWORD) login_page.login(account) products_page = ProductsPage(self.driver) total = products_page.count_broken_images() self.assertEqual(0, total)
def test_login_with_standard_user(self): login_page = LoginPage(self.driver) account = Account(Data.USERNAME_STANDARD_USER, Data.PASSWORD) login_page.login(account) product_page = ProductsPage(self.driver) url = product_page.get_product_url() print(url) self.assertEqual(url, 'https://www.saucedemo.com/inventory.html')
def test_login_standard_user(self): login_page = LoginPage(self.driver) account = Account('standard_user', Data.PASSWORD) login_page.login(account) # time.sleep(5) products_page = ProductsPage(self.driver) url = products_page.get_product_url() # self.assertIn(url, 'https://www.saucedemo.com/inventory.html') self.assertIn('inventory.html', url) print(url)
def test_checkout_products(self): assertion = Assertion() login_page = LoginPage(self.driver) account = Account('standard_user', Data.PASSWORD) login_page.login(account) products = Data.get_products_json(self) products_page = ProductsPage(self.driver) for index in [1, 2, 3]: products_page.click_add_to_cart_button(index) products_page.click_badge_icon() cart_page = CartPage(self.driver) for index in [1, 2, 3]: actual_product = cart_page.get_product_info(index) expected_product = products[index - 1] assertion.compare_products(actual_product, expected_product) cart_page.click_checkout() check_out_step_one_page = CheckOutStepOnePages(self.driver) check_out_step_one = CheckOutStepOne(Data.FIRSTNAME, Data.LASTNAME, Data.POSTALCODE) # check_out_step_one = CheckOutStepOne('a', 'b', '123') check_out_step_one_page.check_out_info(check_out_step_one) check_out_step_one_page.click_continue() check_out_step_two_page = CheckOutStepTwoPages(self.driver) total_price = 0.00 for index in [1, 2, 3]: actual_product = check_out_step_two_page.get_product_info(index) expected_product = products[index - 1] assertion.compare_products(actual_product, expected_product) total_price += Utility().multiple(actual_product.quantity, actual_product.price) self.assertEqual(total_price, check_out_step_two_page.get_item_total()) actual_tax = total_price * 0.08004 self.assertEqual(float("{:.2f}".format(actual_tax)), check_out_step_two_page.get_tax()) actual_total = total_price + actual_tax self.assertEqual(float("{:.2f}".format(actual_total)), check_out_step_two_page.get_total()) print(actual_total) check_out_step_two_page.click_finish()
def test_product2(self): products = Data.read_products_from_json(self) assertion = Assertion() login_page = LoginPage(self.driver) account = Account(Data.USERNAME_STANDARD_USER, Data.PASSWORD) login_page.login(account) product_page = ProductsPage(self.driver) for index in [1, 2, 3]: product_page.click_add_to_cart_button(index) product_page.click_badge_icon() cart_page = CartPage(self.driver) for index in [1, 2, 3]: actual_product = cart_page.get_product_info(index) expected_product = products[index - 1] assertion.compare_products(actual_product, expected_product) cart_page.click_checkout_button() checkout_step_one_page = CheckoutStepOnePage(self.driver) checkout_step_one = CheckoutStepOne('a', 'b', 123) checkout_step_one_page.add_checkout_info(checkout_step_one) checkout_step_one_page.click_continue_button() checkout_step_two_page = CheckoutStepTwoPage(self.driver) total_price = 0.00 for index in [1, 2, 3]: actual_product = checkout_step_two_page.get_product_info(index) expected_product = products[index - 1] assertion.compare_products(actual_product, expected_product) print(actual_product.quantity) total_price += Utility().multiple(actual_product.quantity, actual_product.price) actual_tax = total_price * 0.08004 self.assertEqual(float("{:.2f}".format(actual_tax)), checkout_step_two_page.get_tax()) actual_total = total_price + actual_tax self.assertEqual(float("{:.2f}".format(actual_total)), checkout_step_two_page.get_total()) print(checkout_step_two_page.get_item_total()) print(checkout_step_two_page.get_tax()) print(checkout_step_two_page.get_total()) checkout_step_two_page.click_finish()
def test_product(self): products = Data.getProducts_json(self) assertion = Assertion() login_page = LoginPage(self.driver) account = Account('standard_user', Data.PASSWORD) login_page.login(account) products_page = ProductsPage(self.driver) # for index, expected_product in enumerate(products, start=1): # products_page.click_add_to_cart_button(index) for index in [1, 2, 3]: products_page.click_add_to_cart_button(index) products_page.click_badge_icon() cart_page = CartPage(self.driver) for index in [1, 2, 3]: actual_product = cart_page.get_product_info(index) expected_product = products[index - 1] assertion.compare_products(actual_product, expected_product) # logging.info("Verify products from the cart page are the same with the selected products") # for index in [1, 2, 3]: # assertion.compare_products(cart_page.get_product_info(index), products[index - 1]) cart_page.click_checkout_button() checkout_step_one_page = CheckoutStepOnePage(self.driver) checkoutstepone = CheckoutStepOne('fname', 'lname', 'zipcode') checkout_step_one_page.add_checkout_info(checkoutstepone) checkout_step_one_page.click_continue() checkout_step_two_page = CheckoutStepTwoPage(self.driver) # compare selected products in cart page and checkout two page for index in [1, 2, 3]: actual_product = checkout_step_two_page.get_product_info(index) expected_product = cart_page.get_product_info(index) assertion.compare_products(actual_product, expected_product) checkout_step_two_page.click_finish()
def test_products_display_correctly(self): login_page = LoginPage(self.driver) account = Account(Data.USERNAME_STANDARD_USER, Data.PASSWORD) login_page.login(account) product_page = ProductsPage(self.driver) products = Data.read_products_from_json(self) for index, expected_product in enumerate(products, start=1): '''Add & remove all products''' product_page.click_add_to_cart_button(index) self.assertTrue(product_page.does_remove_button_exist(index)) self.assertEqual(1, product_page.get_badge_total()) product_page.click_remove_button(index) self.assertTrue(product_page.does_add_to_cart_button_exist(index)) self.assertTrue(product_page.is_product_badge_invisible()) actual_product = product_page.get_product_info(index) assertion = Assertion() assertion.compare_products(actual_product, expected_product)
def test_product(self): products = Data.getProducts_json(self) # for index, expected_product in enumerate(products, start=1): # print(expected_product) login_page = LoginPage(self.driver) account = Account('standard_user', Data.PASSWORD) login_page.login(account) products_page = ProductsPage(self.driver) for index, expected_product in enumerate(products, start=1): actual_product = products_page.get_product_info(index) assertion = Assertion() assertion.compare_products(actual_product, expected_product) # total = products_page.get_badge_total() # print(total) # products_page.click_badge_icon() # products_page.click_add_to_cart_button(1) # products_page.click_remove_button(1) # time.sleep(5) # products_page.get_all_products_info() for index, expected_product in enumerate(products, start=1): '"Add & remove all products"' products_page.click_add_to_cart_button(index) self.assertTrue(products_page.does_remove_button_exist(index)) self.assertEqual(1, products_page.get_product_badge()) products_page.click_remove_button(index) self.assertTrue(products_page.does_add_button_exist(index)) self.assertTrue(products_page.is_product_badge_invisible())
def test_product(self): products = Data.getProducts_json(self) assertion = Assertion() login_page = LoginPage(self.driver) account = Account('standard_user', Data.PASSWORD) login_page.login(account) products_page = ProductsPage(self.driver) # for index, expected_product in enumerate(products, start=1): # products_page.click_add_to_cart_button(index) for index in [1, 2, 3]: products_page.click_add_to_cart_button(index) products_page.click_badge_icon() cart_page = CartPage(self.driver) for index in [1, 2, 3]: actual_product = cart_page.get_product_info(index) expected_product = products[index - 1] assertion.compare_products(actual_product, expected_product) # logging.info("Verify products from the cart page are the same with the selected products") # for index in [1, 2, 3]: # assertion.compare_products(cart_page.get_product_info(index), products[index - 1]) cart_page.click_checkout_button() checkout_step_one_page = CheckoutStepOnePage(self.driver) checkoutstepone = CheckoutStepOne('fname', 'lname', 'zipcode') checkout_step_one_page.add_checkout_info(checkoutstepone) checkout_step_one_page.click_continue() checkout_step_two_page = CheckoutStepTwoPage(self.driver) # compare selected products in cart page and checkout two page total_price = 0.00 for index in [1, 2, 3]: actual_product = checkout_step_two_page.get_product_info(index) expected_product = products[index - 1] assertion.compare_products(actual_product, expected_product) print(actual_product.quantity) total_price += Utility().multiple(actual_product.quantity, actual_product.price) payment_info = checkout_step_two_page.get_payment_info() shipping_info = checkout_step_two_page.get_shipping_info() self.assertEqual('SauceCard #31337', payment_info) self.assertEqual('FREE PONY EXPRESS DELIVERY!', shipping_info) # print(checkout_step_two_page.get_item_total()) # print(checkout_step_two_page.get_tax()) # print(checkout_step_two_page.get_total()) print(total_price) self.assertEqual(total_price, checkout_step_two_page.get_item_total()) actual_tax = total_price * 0.08004 self.assertEqual(float("{:.2f}".format(actual_tax)), checkout_step_two_page.get_tax()) print(float("{:.2f}".format(actual_tax))) actual_total = total_price + actual_tax self.assertEqual(float("{:.2f}".format(actual_total)), checkout_step_two_page.get_total()) print(float("{:.2f}".format(actual_total)))