Exemple #1
0
def test_guest_can_add_product_to_basket(browser, url):
    new_link = f"http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer{url}"
    page = ProductPage(browser, new_link)
    page.open()
    page.click_add_to_cart_button(browser)
    page.check_that_product_is_added()
    page.check_that_price_is_correct()
Exemple #2
0
    def test_upsell_on_featured_womens_product(self):
        CONSUMER = "Dam"
        PRODUCT_CATEGORY = "Underkläder"
        EXPECTED_URL = "https://www.sportamore.se/dam/klader/underklader/"
        EXPECTED_UPSELL = {'Slim 500ml', '3Ppk Value No Show'}

        driver = self.driver

        # navigate from the Main page to "herr/byxor" via hover-menu
        main_page = MainPage(driver)
        main_page.go_to_consumer_product_category(CONSUMER, PRODUCT_CATEGORY)

        # click on the featured product
        consumer_product_category_page = ConsumerProductCategoryPage(driver)
        current_url = consumer_product_category_page.current_url
        self.assertEqual(current_url, EXPECTED_URL)
        consumer_product_category_page.go_to_featured_product()

        # proceed to quantity selection
        product_page = ProductPage(driver)
        # ↓ an abstraction leak to demo flexibility
        product_page.size_select.select_first_size()
        product_page.go_to_add_to_cart()

        # check the actual upsell products against expected
        add_to_cart_page = AddToShoppingCartPage(driver)
        actual_upsell = add_to_cart_page.get_upsell_items()

        self.assertTrue(EXPECTED_UPSELL.issubset(actual_upsell),
                "Unexpected upsell items: {}".format(
                    EXPECTED_UPSELL.difference(actual_upsell)
                )
        )
Exemple #3
0
def delete_product(get_driver, go_to_product_page, product_dataset_more):
    """fixture to delete product test"""
    product_page = ProductPage(get_driver, go_to_product_page)
    product_page.navigate()
    product_name, product_meta_tag_title, product_model = product_dataset_more
    product_page.add_product(product_name, product_meta_tag_title, product_model)
    product_page.delete_product()
    current_result = product_page.get_alert()
    expected_result = "Success: You have modified products!"
    return expected_result, current_result
Exemple #4
0
    def run(self):

        if WATCH_MODE:
            self.watch_release()

        option = Options()

        if PROXY:
            option.add_argument('--proxy-server=http://%s' % PROXY)

        driver = webdriver.Chrome(executable_path=CHROME_DRIVER_PATH,
                                  options=option)
        driver.set_window_position(self.window_position_x,
                                   self.window_position_y)
        driver.set_window_size(self.window_width, self.window_height)

        shop_all_page = ShopAllPage(driver)
        shop_all_page.open()

        for i, product in enumerate(self.products):
            if not self.check_product_existance(product):
                logging.info('Product "' + product['name'] + '" not found')
                continue
            elif not self.check_stock(product):
                logging.info('Product "' + product['name'] + '" is sold out')
                continue
            else:
                logging.info('Product "' + product['name'] + '" is in stock')

                shop_all_page.click_product(product['href'])
                product_page = ProductPage(shop_all_page.driver)
                if product['size'] is not None:
                    product_page.select_size(product['size'])
                product_page.add_to_cart()
                sleep(ADD_TO_CART_DELAY)

                logging.info(f'Product "{product["name"]}" is added to cart')

                if i == len(self.products) - 1:
                    product_page.checkout()
                    checkout_page = CheckoutPage(product_page.driver)
                    checkout_page.fillout()
                    logging.info('Checkout info filled out')
                    # if AUTO_PROCESS_PAYMENT:
                    #     checkout_page.process_payment()
                else:
                    product_page.shop_all()
                    shop_all_page = ShopAllPage(product_page.driver)

                sleep(MANUAL_ADJUSTMENT_TIME)
def test_guest_cant_see_success_message_after_adding_product_to_basket(
        browser):
    link = "http://selenium1py.pythonanywhere.com/catalogue/the-shellcoders-handbook_209/"
    page = ProductPage(browser, link, timeout=0)
    page.open()
    page.add_product_to_basket()
    page.is_not_succsess_message_present()
def test_guest_can_go_to_login_page_from_product_page(browser):
    link = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the-city-and-the-stars_95/"
    page = ProductPage(browser, link)
    page.open()
    page.should_be_login_link()
    page.go_to_login_page()
    login_page = LoginPage(browser, browser.current_url)
    login_page.should_be_login_page()
Exemple #7
0
    def test_checkout_process(self):
        # Get Header Nav Elements
        # self.home_page.get_header_elements()
        self.home_page.search_and_submit("jimi hendrix stratocaster")
        time.sleep(3)

        # Product Page validation
        self.product = ProductPage(self.driver)
        self.product.wait_until_title_contains("Jimi Hendrix")
        self.product.get_metadata_elements()

        self.assertIn("JIMI HENDRIX STRATOCASTER", self.product.product_header_text)
        self.assertEquals("OLYMPIC WHITE", self.product.selected_color_text)
        self.assertEquals("MAPLE", self.product.fingerboard_material_text)
        self.assertEquals("0145802305", self.product.model_number_text)

        self.product.add_to_cart()
        time.sleep(2) # Refactor! Should be using a proper wait here or ...
        self.assertTrue(self.product.mini_cart_content_is_displayed())
        self.product.get_mini_cart_quantity() # ...in this method
        self.assertEquals(self.product.mini_cart_quantity, 1)

        # Mini Cart Validation
        self.product.get_mini_cart_product_metadata(1)
        self.assertEquals(self.product.product_header_text, self.product.mini_cart_item_1_name)
        self.assertEquals(self.product.selected_color_text.lower(), self.product.mini_cart_item_1_color.lower())
        self.assertEquals(self.product.fingerboard_material_text.lower(), self.product.mini_cart_item_1_fingerboard.lower())
        self.assertEquals(self.product.price_text, self.product.mini_cart_item_1_price)
        self.assertEquals(self.product.mini_cart_item_1_quantity, 1)

        self.product.click_mini_cart_button()

        # Cart Page Validation
        self.cart = CartPage(self.driver)
        self.cart.wait_until_title_contains("Cart")
        self.cart.get_cart_product_metadata()

        self.assertIn("JIMI HENDRIX STRATOCASTER", self.cart.cart_item_name)
        self.assertEquals(self.cart.cart_item_model_number, "0145802305")
        self.assertEquals(self.cart.cart_item_color, "Olympic White")
        self.assertEquals(self.cart.cart_item_fingerboard, "Maple")
        self.assertEquals(self.cart.cart_item_price, "$899.99")
        self.assertEquals(self.cart.cart_item_quantity, "1")

        self.cart.click_secure_checkout_button()
        time.sleep(5)

        # Checkout as guest
        self.checkout_login = CheckoutLoginPage(self.driver)
        self.checkout_login.click_checkout_as_guest_button()
        time.sleep(3)

        # Shipping Page Data Entry
        self.shipping = ShippingPage(self.driver)
        self.shipping.fill_in_and_submit_shipping_address()
        time.sleep(5)
Exemple #8
0
def add_product(add_waits, go_to_product_page, product_dataset):
    """fixture to add product test"""
    product_page = ProductPage(add_waits, go_to_product_page)
    product_page.navigate()
    product_name, product_meta_tag_title, product_model = product_dataset
    product_page.add_product(product_name, product_meta_tag_title, product_model)
    current_result = product_page.get_alert()
    expected_result = "Success: You have modified products!"
    return expected_result, current_result
def test_add_product_to_cart_from_product_page(browser):
    QTY = 2

    product_page = ProductPage(browser)
    product_page.open()
    product_price = product_page.get_product_price()
    product_page.set_quantity(QTY)
    product_page.add_to_cart()

    assert Alert(browser).alert

    top_menu = TopMenu(browser)
    cart_total_amount = top_menu.get_cart_text()

    product_price = float(product_price.replace("$", ""))

    assert str(product_price * QTY) in cart_total_amount
def test_guest_cant_see_product_in_basket_opened_from_product_page(browser):
    link = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the-city-and-the-stars_95/"
    page = ProductPage(browser, link)
    page.open()
    page.go_to_basket_page()
    basket_page = BasketPage(browser, browser.current_url)
    basket_page.should_be_empty()
Exemple #11
0
def test_guest_cant_see_product_in_cart_opened_from_product_page(browser):
    page = ProductPage(browser, product_link)
    page.open()
    page.go_to_cart_page()
    cart_page = CartPage(browser, browser.current_url)
    cart_page.cart_is_empty()
    cart_page.empty_cart_subtitle()
def test_open_product_card_from_catalog(browser):
    CATEGORY = 'Tablets'

    category_page = CategoriesPage(browser)
    category_page.open()

    NavigationBar(browser).open_page()
    NavigationBar(browser).open_section_by_name(CATEGORY)

    section_title = category_page.get_category_name()
    assert section_title == CATEGORY

    product_name = category_page.get_product_name_in_minicard()
    print("product_name", product_name)
    category_page.open_product_card()

    product_title = ProductPage(browser).get_product_name()
    assert product_title == product_name
Exemple #13
0
 def test_user_can_add_product_to_cart(self, browser):
     page = ProductPage(browser, product_link)
     page.open()
     page.should_be_add_to_cart_button()
     page.add_to_cart()
     page.product_added()
     page.product_price()
Exemple #14
0
def test_guest_cant_see_success_message_after_adding_product_to_basket(
        browser):
    page = ProductPage(browser, link)
    page.open()
    page.click_add_to_cart_button(browser)
    page.should_not_be_success_message()
def test_guest_should_see_login_link_on_product_page(browser):
    link = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the-city-and-the-stars_95/"
    page = ProductPage(browser, link)
    page.open()
    page.should_be_login_link()
Exemple #16
0
def test_message_disappeared_after_adding_product_to_basket(browser):
    page = ProductPage(browser, link)
    page.open()
    page.click_add_to_cart_button(browser)
    page.should_disappear()
def test_guest_can_add_product_to_basket(browser):
    link = "http://selenium1py.pythonanywhere.com/catalogue/the-shellcoders-handbook_209/?promo=newYear"
    page = ProductPage(browser, link)
    page.open()
    page.add_product_to_basket()
def test_guest_can_add_product_to_basket_bug(browser, link):
    page = ProductPage(browser, link)
    page.open()
    page.add_product_to_basket()
Exemple #19
0
def test_guest_can_go_to_login_page_from_product_page(browser):
    new_link = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the-city-and-the-stars_95/"
    page = ProductPage(browser, new_link)
    page.open()
    page.go_to_login_page()
Exemple #20
0
def test_guest_can_go_to_login_page_from_product_page(browser):
    page = ProductPage(browser, product_link)
    page.open()
    page.go_to_login_page()
Exemple #21
0
def test_guest_should_see_login_link_on_product_page(browser):
    page = ProductPage(browser, product_link)
    page.open()
    page.should_be_login_link()
Exemple #22
0
def test_message_disappeared_after_adding_product_to_cart(browser):
    page = ProductPage(browser, product_link)
    page.open()
    page.add_to_cart()
    page.success_message_should_dissapear()
Exemple #23
0
def test_guest_cant_see_success_message(browser):
    page = ProductPage(browser, product_link)
    page.open()
    page.should_not_be_success_message()
Exemple #24
0
 def test_user_can_add_product_to_basket(self, browser):
     page = ProductPage(browser, link)
     page.open()
     page.click_add_to_cart_button(browser)
     page.check_that_product_is_added()
     page.check_that_price_is_correct()
Exemple #25
0
def test_guest_cant_see_product_in_basket_opened_from_product_page(browser):
    page = ProductPage(browser, link)
    page.open()
    page.go_to_cart()
    basket_page = BasketPage(browser, browser.current_url)
    basket_page.should_be_empty_basket()
Exemple #26
0
def test_guest_can_add_product_to_cart(browser, link):
    page = ProductPage(browser, link)
    page.open()
    page.should_be_add_to_cart_button()
    page.add_to_cart()
    page.product_added()
    page.product_price()
Exemple #27
0
def test_guest_cant_see_success_message_after_adding_product_to_cart(browser):
    page = ProductPage(browser, product_link)
    page.open()
    page.add_to_cart()
    page.should_not_be_success_message()
Exemple #28
0
 def test_user_cant_see_success_message(self, browser):
     page = ProductPage(browser, link)
     page.open()
     page.should_not_be_success_message()