def test_fill_billing_details(self, setup): self.driver.get("http://shop.demoqa.com/shop/") main_page = MainPage(self.driver) products_list = ProductsList(self.driver) product_page = ProductPage(self.driver) shopping_cart = ShoppingCartPage(self.driver) checkout = CheckoutPage(self.driver) first_product = products_list.find_first_product() main_page.click_on_search_field() main_page.fill_search_field(first_product) product_page.select_colour() product_page.select_size() self.driver.execute_script("scroll(0, 792)") product_page.add_to_cart_first_product() product_page.view_cart() time.sleep(2) self.driver.execute_script("scroll(0, 923)") shopping_cart.proceed_to_checkout() checkout.insert_billing_name() checkout.insert_billing_lastname() checkout.insert_billing_company() checkout.select_billing_country() checkout.insert_house_and_street() checkout.insert_billing_apartment() checkout.insert_billing_postcode() checkout.insert_billing_city() checkout.insert_billing_phone() checkout.insert_billing_email() time.sleep(2) checkout.tick_terms_checkbox() checkout.place_order() assert "Your order has been received" in self.driver.find_element_by_class_name( CheckoutLocators.order_received_class).text
def test_switch_between_tabs(self, setup): self.driver.get("http://shop.demoqa.com/shop/") main_page = MainPage(self.driver) product_page = ProductPage(self.driver) products_list = ProductsList(self.driver) main_page.close_information_banner() first_product = products_list.find_first_product() main_page.click_on_search_field() main_page.fill_search_field(first_product) product_page.select_colour() product_page.select_size() self.driver.execute_script("scroll(0, 350)") product_page.add_to_cart_first_product() time.sleep(3) main_page.click_on_main_logo() main_page.click_on_checkout() assert "CHECKOUT" in self.driver.find_element_by_class_name(MainPageLocators.page_title_class).text main_page.click_on_my_account() assert "MY ACCOUNT" in self.driver.find_element_by_class_name(MainPageLocators.page_title_class).text main_page.click_on_my_wishlist() assert "WISHLIST" in self.driver.find_element_by_class_name(MainPageLocators.page_title_class).text main_page.click_on_shopping_cart() assert "CART" in self.driver.find_element_by_class_name(MainPageLocators.page_title_class).text
def test_remove_from_shopping_cart(self, setup): self.driver.get("http://shop.demoqa.com/shop/") main_page = MainPage(self.driver) products_list = ProductsList(self.driver) product_page = ProductPage(self.driver) shopping_cart = ShoppingCartPage(self.driver) first_product = products_list.find_first_product() main_page.click_on_search_field() main_page.fill_search_field(first_product) product_page.select_colour() product_page.select_size() self.driver.execute_script("scroll(0, 350)") product_page.add_to_cart_first_product() product_page.view_cart() time.sleep(2) self.driver.execute_script("scroll(0, 350)") shopping_cart.remove_from_cart() assert "removed" in self.driver.find_element_by_class_name(ShoppingCartLocators.successfully_removed_class).text
def test_proceed_to_checkout(self, setup): self.driver.get("http://shop.demoqa.com/shop/") main_page = MainPage(self.driver) products_list = ProductsList(self.driver) product_page = ProductPage(self.driver) shopping_cart = ShoppingCartPage(self.driver) first_product = products_list.find_first_product() main_page.click_on_search_field() main_page.fill_search_field(first_product) time.sleep(3) self.driver.execute_script("scroll(0, 300)") product_page.select_colour() product_page.select_size() product_page.add_to_cart_first_product() product_page.view_cart() time.sleep(3) self.driver.execute_script("scroll(0, 700)") shopping_cart.proceed_to_checkout() assert self.driver.find_element_by_id(CheckoutLocators.order_review_heading_id).is_displayed()
def test_continue_shopping(self, setup): self.driver.get("http://shop.demoqa.com/shop") main_page = MainPage(self.driver) products_list = ProductsList(self.driver) product_page = ProductPage(self.driver) shopping_cart = ShoppingCartPage(self.driver) first_product = products_list.find_first_product() main_page.click_on_search_field() main_page.fill_search_field(first_product) time.sleep(3) self.driver.execute_script("scroll(0, 300)") product_page.select_colour() product_page.select_size() product_page.add_to_cart_first_product() product_page.view_cart() time.sleep(3) self.driver.execute_script("scroll(0, 500)") shopping_cart.continue_shopping() assert self.driver.find_element_by_xpath(ProductsListLocators.products_list_xpath).is_displayed()
def test_update_shopping_cart(self, setup): self.driver.get("http://shop.demoqa.com/shop/") main_page = MainPage(self.driver) products_list = ProductsList(self.driver) product_page = ProductPage(self.driver) shopping_cart = ShoppingCartPage(self.driver) first_product = products_list.find_first_product() main_page.click_on_search_field() main_page.fill_search_field(first_product) time.sleep(3) self.driver.execute_script("scroll(0, 300)") product_page.select_colour() product_page.select_size() product_page.add_to_cart_first_product() product_page.view_cart() time.sleep(3) self.driver.execute_script("scroll(0, 500)") shopping_cart.increase_qty() shopping_cart.update_cart() time.sleep(2) assert "updated" in self.driver.find_element_by_xpath(ShoppingCartLocators.successfully_updated_xpath).text
def test_add_product_to_cart(self, setup): self.driver.get("http://shop.demoqa.com/shop/") main_page = MainPage(self.driver) products_list = ProductsList(self.driver) product_page = ProductPage(self.driver) shopping_cart = ShoppingCartPage(self.driver) first_product = products_list.find_first_product() main_page.click_on_search_field() main_page.fill_search_field(first_product) product_page.select_colour() product_page.select_size() self.driver.execute_script("scroll(0, 350)") product_page.add_to_cart_first_product() assert "has been added to your cart" in self.driver.find_element_by_class_name(ProductPageLocators.product_added_to_cart_class).text price1 = product_page.get_product_price() price2 = main_page.get_product_price() product_page.view_cart() price3 = shopping_cart.get_product_price() assert "1" in self.driver.find_element_by_class_name(MainPageLocators.cart_count_class).get_attribute("textContent") assert price1 == price2 == price3