def test_clear_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()
        second_product = products_list.find_second_product()
        #select first product
        main_page.click_on_search_field()
        main_page.fill_search_field(first_product)
        time.sleep(3)
        self.driver.execute_script("scroll(0, 500)")
        product_page.select_colour()
        product_page.select_size()
        product_page.add_to_cart_first_product()
        time.sleep(3)
        #select second product
        main_page.click_on_search_field()
        main_page.fill_search_field(second_product)
        time.sleep(3)
        self.driver.execute_script("scroll(0, 500)")
        product_page.select_colour()
        product_page.select_size()
        product_page.add_to_cart_second_product()
        product_page.view_cart()
        time.sleep(2)
        self.driver.execute_script("scroll(0, 500)")
        shopping_cart.clear_cart()

        assert "empty" in self.driver.find_element_by_xpath(ShoppingCartLocators.successfully_emptied_xpath).text
Beispiel #2
0
    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
Beispiel #3
0
    def test_click_wishlist_from_mainpage(self, setup):
        self.driver.get("http://shop.demoqa.com")
        main_page = MainPage(self.driver)

        main_page.close_information_banner()
        main_page.click_on_my_wishlist()
        assert "WISHLIST" in self.driver.find_element_by_class_name(MainPageLocators.page_title_class).text
Beispiel #4
0
    def test_click_checkout_from_mainpage_emptycart(self, setup):
        self.driver.get("http://shop.demoqa.com")
        main_page = MainPage(self.driver)

        main_page.close_information_banner()
        main_page.click_on_checkout()
        # If we do not have any items in the shopping cart, we will be redirected to the shopping cart
        assert "CART" in self.driver.find_element_by_class_name(MainPageLocators.page_title_class).text
    def test_search_available_product(self, setup):
        self.driver.get("http://shop.demoqa.com/")
        main_page = MainPage(self.driver)

        main_page.click_on_search_field()
        main_page.fill_search_field("dress")

        assert self.driver.find_element_by_xpath(
            ProductsListLocators.products_list_xpath).is_displayed()
Beispiel #6
0
    def test_register_account(self, setup):
        self.driver.get("http://shop.demoqa.com/")
        main_page = MainPage(self.driver)
        my_account_page = MyAccount(self.driver)

        main_page.close_information_banner()
        main_page.click_on_my_account()
        my_account_page.fill_random_reg_username("TestName")
        my_account_page.fill_random_reg_mail("*****@*****.**")
        my_account_page.fill_reg_password("Testtesttest!")
        my_account_page.perform_register()

        assert "Back to ToolsQA Demo Site" in self.driver.find_element_by_xpath(
            MyAccountLocators.back_to_blog_button_xpath).text
Beispiel #7
0
    def test_log_in(self, setup):
        self.driver.get("http://shop.demoqa.com/")
        main_page = MainPage(self.driver)
        my_account_page = MyAccount(self.driver)

        main_page.close_information_banner()
        main_page.click_on_my_account()
        my_account_page.fill_random_reg_username("TestName")
        username = my_account_page.get_reg_username()
        my_account_page.fill_random_reg_mail("*****@*****.**")
        my_account_page.fill_reg_password("Testtesttest!")
        password = my_account_page.get_reg_password()
        my_account_page.perform_register()
        my_account_page.go_back_to_shop()

        main_page.click_on_my_account()
        my_account_page.fill_login_or_mail(username)
        my_account_page.fill_login_password(password)
        my_account_page.perform_login()

        assert "Logout" in self.driver.find_element_by_xpath(
            MyAccountLocators.logout_button_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
    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()
Beispiel #12
0
    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