def test_plp_prices(driver, browser, mode, device, username, password):
    """ Check that the PLP prices match the PDP prices. """
    login_page = LoginPage(driver)
    login_page.perform_complete_login(username, password)
    product_page = ProductListPage(driver)
    product_elements = product_page.get_all_product_elements()

    product_link_map = {}
    product_price_map = {}
    for product in product_elements:
        product_name = product.find_element_by_class_name("inventory_item_name").text
        product_url = product.find_element_by_xpath(".//div[2]/a").get_attribute("href")
        product_price = product.find_element_by_class_name("inventory_item_price").text
        product_link_map[product_name] = product_url
        product_price_map[product_name] = product_price

    bad_prices = []
    for product, link in product_link_map.items():
        driver.get(link)
        pdp_page = ProductDetailPage(driver)
        pdp_price = pdp_page.get_price()
        if pdp_price != product_price_map[product]:
            print("The price for {0} was not correct: {1}".format(product, pdp_price))
            bad_prices.append(product)
        time.sleep(3)

    assert len(bad_prices) == 0, str(len(bad_prices)) + " incorrect prices were found on the PLP."
Exemplo n.º 2
0
def test_blackShoesDetail_quantityAddToCart_task3(py, report_generator, width,
                                                  height, displayType,
                                                  location, testName):
    filterPage = ProductDetailPage(
        py, width, height, py.config.custom['environment']['productDetailUrl'],
        backShoe1Page)

    assert filterPage.getDefaultQuantity() == '1'
Exemplo n.º 3
0
def test_blackShoesDetail_addToCardButton_task3(py, report_generator, width,
                                                height, displayType, location,
                                                testName):
    filterPage = ProductDetailPage(
        py, width, height, py.config.custom['environment']['productDetailUrl'],
        backShoe1Page)

    assert filterPage.getButtonAddToCart().is_enabled()
Exemplo n.º 4
0
def test_blackShoesDetail_price_task3(py, report_generator, width, height,
                                      displayType, location, testName):
    filterPage = ProductDetailPage(
        py, width, height, py.config.custom['environment']['productDetailUrl'],
        backShoe1Page)

    # Using a regexp to check that price starts with $, then several digit, then a '.' and 2 more digits
    assert re.search("[$][0-9]+.[0-9]{2}", filterPage.getPrize()) is not None
Exemplo n.º 5
0
def test_blackShoesDetail_defaultSize_task3(py, report_generator, width,
                                            height, displayType, location,
                                            testName):
    filterPage = ProductDetailPage(
        py, width, height, py.config.custom['environment']['productDetailUrl'],
        backShoe1Page)

    filterPage.getDefaultSize().should().have_text('Small (S)')
Exemplo n.º 6
0
def test_blackShoesDetail_productPrevDisplay_task3(py, report_generator, width,
                                                   height, displayType,
                                                   location, testName):
    filterPage = ProductDetailPage(
        py, width, height, py.config.custom['environment']['productDetailUrl'],
        backShoe1Page)
    styleShoeImage = filterPage.getShoeImage()

    assert 'url' in styleShoeImage
Exemplo n.º 7
0
def test_blackShoesDetail_topToolsIcons_task3(py, report_generator, width,
                                              height, displayType, location,
                                              testName):
    filterPage = ProductDetailPage(
        py, width, height, py.config.custom['environment']['productDetailUrl'],
        backShoe1Page)
    filterPage.useGlobalPageMap(
    )  # Elements Cart_Button, Profile_icon and Wishlist_icon are in GlobalPage

    assert filterPage.checkTopToolsIconsNotOverlapping()
Exemplo n.º 8
0
def test_blackShoesDetail_ratingStarReviews_task3(py, report_generator, width,
                                                  height, displayType,
                                                  location, testName):
    filterPage = ProductDetailPage(
        py, width, height, py.config.custom['environment']['productDetailUrl'],
        backShoe1Page)

    # @Todo: ID has been changed from "#EM____82" (v1) to "#EM__ratingcoun__82" (v2) :'(
    # Issue (33934) created : 3) Hackathon – App issue: Rating count ID has been changed between v1 and v2
    # Change ID in ProductDetailPageMap
    assert filterPage.checkRatingReviewOverlapping()
def test_add_to_cart_button(driver, browser, mode, device, username, password):
    """Test the PDP's add to cart button."""
    login_page = LoginPage(driver)
    login_page.perform_complete_login(username, password)
    product_list_page = ProductListPage(driver)

    # Get a random product
    products = product_list_page.get_all_product_elements()
    index = random.randrange(0, len(products))
    product = products[index]
    product_url = product.find_element_by_xpath(
        product_list_page.URL_XPATH).get_attribute("href")
    driver.get(product_url)
    pdp = ProductDetailPage(driver)
    pdp.click_add_to_cart()
    assert pdp.get_number_cart_items() == 1
Exemplo n.º 10
0
def test_blackShoesDetail_reference_task3(py, report_generator, width, height,
                                          displayType, location, testName):
    filterPage = ProductDetailPage(
        py, width, height, py.config.custom['environment']['productDetailUrl'],
        backShoe1Page)

    # "displayed" means that the element is in the DOM and has a size
    #  greater than zero such that it is visible to the user.
    # @Todo: so it returns true even if element is not visible (white on white).
    #  getCssValue not supported by pylenium :/
    reference = filterPage.getReference()
    # refWebElement = reference.webelement
    # backgroundColor = refWebElement.getCssValue("background-color")
    # color = refWebElement.getCssValue("color")
    # print("Color: "+color)
    # print("backgroundColor: " + backgroundColor)
    assert (reference.is_displayed())
def test_plp_links(driver, browser, mode, device, username, password):
    """ Test to ensure that the PLP product link properly redirects to the associated PDP."""
    login_page = LoginPage(driver)
    login_page.perform_complete_login(username, password)
    product_page = ProductListPage(driver)
    product_elements = product_page.get_all_product_elements()

    product_link_map = {}
    for product in product_elements:
        product_name = product.find_element_by_class_name("inventory_item_name").text
        product_url = product.find_element_by_xpath(".//div[2]/a").get_attribute("href")
        product_link_map[product_name] = product_url

    bad_links = []
    for product, link in product_link_map.items():
        driver.get(link)
        pdp_page = ProductDetailPage(driver)
        pdp_product_name = pdp_page.get_product_name()
        if pdp_product_name != product:
            print("The PLP link for {0} was not correct: {1}".format(product, link))
            bad_links.append(product)

    assert len(bad_links) == 0, str(len(bad_links)) + " incorrect links were found on the PLP."