Exemplo n.º 1
0
def test_single_page_checkout_with_login_and_register(browser, live_server,
                                                      settings):
    cache.clear()  # Avoid caches from past tests

    # initialize
    product_name = "Test Product"
    get_default_shop()
    get_default_payment_method()
    get_default_shipping_method()
    product = create_orderable_product(product_name, "test-123", price=100)
    OrderStatus.objects.create(identifier="initial",
                               role=OrderStatusRole.INITIAL,
                               name="initial",
                               default=True)

    # Initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    wait_until_condition(browser,
                         lambda x: x.is_text_present("Welcome to Default!"))
    navigate_to_checkout(browser, product)

    # Let's assume that after addresses the checkout is normal
    wait_until_condition(browser,
                         lambda x: x.is_text_present("Checkout Method"))
    test_username = "******"
    test_email = "*****@*****.**"
    test_password = "******"
    register_test(browser, live_server, test_username, test_email,
                  test_password)

    login_and_finish_up_the_checkout(browser, live_server, test_username,
                                     test_email, test_password)
Exemplo n.º 2
0
def test_category_product_filters_2(browser, live_server, settings):
    cache.clear()  # Avoid cache from past tests
    shop, first_cat, second_cat, third_cat, first_manufacturer = initialize_db(
    )

    # Activate limit page size changer for the shop
    set_configuration(shop=shop,
                      data={
                          "sort_products_by_name": True,
                          "sort_products_by_name_ordering": 1,
                          "sort_products_by_price": True,
                          "sort_products_by_price_ordering": 2,
                          "limit_product_list_page_size": True
                      })

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    # check that front page actually loaded
    wait_until_condition(browser,
                         lambda x: x.is_text_present("Welcome to Default!"))

    url = reverse("shuup:category",
                  kwargs={
                      "pk": first_cat.pk,
                      "slug": first_cat.slug
                  })
    browser.visit("%s%s" % (live_server, url))
    wait_until_condition(browser,
                         lambda x: x.is_text_present("First Category"))
    wait_until_condition(browser, lambda x: x.is_text_present("Sort"))
    assert not browser.is_text_present(
        "Manufacturers")  # Since not in default configuration
    second_category_sort_test(browser, live_server, shop, second_cat)
    second_category_sort_with_price_filter(browser, second_cat)
Exemplo n.º 3
0
def test_recently_viewed_products(browser, live_server, settings):
    shop = get_default_shop()
    category = get_default_category()
    category.shops.add(shop)
    category.status = CategoryStatus.VISIBLE
    category.save()
    category_url = reverse("shuup:category",
                           kwargs={
                               "pk": category.pk,
                               "slug": category.slug
                           })
    browser = initialize_front_browser_test(browser, live_server)
    for i in range(1, 7):
        product = new_product(i, shop, category)
        product_url = reverse("shuup:product",
                              kwargs={
                                  "pk": product.pk,
                                  "slug": product.slug
                              })
        browser.visit(live_server + product_url)
        wait_until_appeared(browser, ".product-main")
        browser.visit(live_server + category_url)
        wait_until_appeared(browser, ".categories-nav")
        items = browser.find_by_css(".recently-viewed li")
        assert items.first.text == product.name, "recently clicked product on top"
        assert len(items) == min(i, 5)
Exemplo n.º 4
0
def test_checkout_with_login_and_register(browser, live_server, settings):
    # initialize
    product_name = "Test Product"
    get_default_shop()
    pm = get_default_payment_method()
    sm = get_default_shipping_method()
    product = create_orderable_product(product_name, "test-123", price=100)
    OrderStatus.objects.create(
        identifier="initial",
        role=OrderStatusRole.INITIAL,
        name="initial",
        default=True
    )

    # Initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    assert browser.is_text_present("Welcome to Default!")
    navigate_to_checkout(browser, product)

    # Let's assume that after addresses the checkout is normal
    assert browser.is_text_present("Checkout: Choose Checkout Method")
    guest_ordering_test(browser, live_server)

    test_username = "******"
    test_email = "*****@*****.**"
    test_password = "******"
    assert browser.is_text_present("Checkout: Choose Checkout Method")
    register_test(browser, live_server, test_username, test_email, test_password)

    assert browser.is_text_present("Checkout: Choose Checkout Method")
    login_and_finish_up_the_checkout(browser, live_server, test_username, test_email, test_password)
def test_single_page_checkout_with_login_and_register(browser, live_server, settings):
    # initialize
    product_name = "Test Product"
    get_default_shop()
    pm = get_default_payment_method()
    sm = get_default_shipping_method()
    product = create_orderable_product(product_name, "test-123", price=100)
    OrderStatus.objects.create(
        identifier="initial",
        role=OrderStatusRole.INITIAL,
        name="initial",
        default=True
    )

    # Initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    wait_until_condition(browser, lambda x: x.is_text_present("Welcome to Default!"))
    navigate_to_checkout(browser, product)

    # Let's assume that after addresses the checkout is normal
    wait_until_condition(browser, lambda x: x.is_text_present("Checkout Method"))
    test_username = "******"
    test_email = "*****@*****.**"
    test_password = "******"
    register_test(browser, live_server, test_username, test_email, test_password)

    login_and_finish_up_the_checkout(browser, live_server, test_username, test_email, test_password)
Exemplo n.º 6
0
def test_category_product_filters_1(browser, live_server, settings):
    cache.clear()  # Avoid cache from past tests
    shop, first_cat, second_cat, third_cat, first_manufacturer = initialize_db(
    )

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    # check that front page actually loaded
    wait_until_condition(browser,
                         lambda x: x.is_text_present("Welcome to Default!"))

    url = reverse("shuup:category",
                  kwargs={
                      "pk": first_cat.pk,
                      "slug": first_cat.slug
                  })
    browser.visit("%s%s" % (live_server, url))
    wait_until_condition(browser,
                         lambda x: x.is_text_present("First Category"))
    wait_until_condition(browser, lambda x: x.is_text_present("Sort"))
    assert not browser.is_text_present(
        "Manufacturers")  # Since not in default configuration
    hide_sorts_for_shop(browser, shop)
    show_sorts_for_the_category_only(browser, first_cat)
    second_category_page_change(browser, live_server, shop, second_cat)
Exemplo n.º 7
0
def test_product_descriptions(browser, live_server, settings):
    activate("en")
    cache.clear()
    shop = get_default_shop()
    product = create_product("product1",
                             shop=shop,
                             description="<b>My HTML description</b>",
                             short_description="some short of description instead",
                             supplier=get_default_supplier())
    sp = ShopProduct.objects.get(product=product, shop=shop)
    sp.primary_category = get_default_category()
    sp.categories.add(get_default_category())
    sp.save()

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    # view product detail page
    url = reverse("shuup:product", kwargs={"pk": product.pk, "slug": product.slug})
    browser.visit("%s%s" % (live_server, url))
    wait_until_condition(browser, lambda x: x.is_text_present(product.short_description))
    assert product.description in browser.html

    # ensure the version is in static files
    assert "style.css?v=%s" % shuup.__version__ in browser.html

    # product preview
    url = reverse("shuup:xtheme_extra_view", kwargs={"view": "products"})
    browser.visit("%s%s" % (live_server, url))
    product_div_name = "product-{}".format(product.pk)
    wait_until_condition(browser, lambda x: x.find_by_css("#{} button.btn".format(product_div_name)))
    browser.execute_script("$('#{} button.btn').click();".format(product_div_name))
    assert product.short_description == browser.find_by_css("#{} p.description".format(product_div_name))[0].html
Exemplo n.º 8
0
def test_category_product_filters_4(browser, live_server, settings):
    """
    Do not show manufacturer option if there is any product
    """
    cache.clear()  # Avoid cache from past tests
    shop, first_cat, second_cat, third_cat, first_manufacturer = initialize_db(
    )

    # remove manufacturers from all products
    Product.objects.all().update(manufacturer=None)
    # show manufacturer filter
    set_configuration(category=first_cat,
                      data={
                          "sort_products_by_name": True,
                          "sort_products_by_name_ordering": 1,
                          "sort_products_by_price": True,
                          "sort_products_by_price_ordering": 2,
                          "filter_products_by_manufacturer": True
                      })

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    # check that front page actually loaded
    wait_until_condition(browser,
                         lambda x: x.is_text_present("Welcome to Default!"))

    url = reverse("shuup:category",
                  kwargs={
                      "pk": first_cat.pk,
                      "slug": first_cat.slug
                  })
    browser.visit("%s%s" % (live_server, url))
    wait_until_condition(browser,
                         lambda x: x.is_text_present("First Category"))
    wait_until_condition(browser, lambda x: x.is_text_present("Sort"))
    assert not browser.is_text_present(
        "Manufacturers")  # Since there is no product with manufacturer

    # add the manufacturer to the last product so the manufacturer filter is show
    last_product = Product.objects.last()
    last_product.manufacturer = first_manufacturer
    last_product.save()
    browser.visit("%s%s" % (live_server, url))
    assert browser.is_text_present("Manufacturers")

    # set the shop product hidden
    shop_product = last_product.get_shop_instance(shop)
    shop_product.visibility = ShopProductVisibility.NOT_VISIBLE
    shop_product.save()

    # the manufacturer filter is removed
    browser.visit("%s%s" % (live_server, url))
    assert not browser.is_text_present("Manufacturers")
def test_recently_viewed_products(browser, live_server, settings):
    shop = get_default_shop()
    category = get_default_category()
    category.shops.add(shop)
    category.status = CategoryStatus.VISIBLE
    category.save()
    category_url = reverse("shuup:category", kwargs={"pk": category.pk, "slug": category.slug})
    browser = initialize_front_browser_test(browser, live_server)
    for i in range(1, 7):
        product = new_product(i, shop, category)
        product_url = reverse("shuup:product", kwargs={"pk": product.pk, "slug": product.slug})
        browser.visit(live_server + product_url)
        wait_until_appeared(browser, ".product-main")
        browser.visit(live_server + category_url)
        wait_until_appeared(browser, ".categories-nav")
        items = browser.find_by_css(".recently-viewed li")
        assert items.first.text == product.name, "recently clicked product on top"
        assert len(items) == min(i, 5)
Exemplo n.º 10
0
def test_product_descriptions(browser, live_server, settings):
    activate("en")
    cache.clear()
    shop = get_default_shop()
    product = create_product(
        "product1",
        shop=shop,
        description="<b>My HTML description</b>",
        short_description="some short of description instead",
        supplier=get_default_supplier())
    sp = ShopProduct.objects.get(product=product, shop=shop)
    sp.primary_category = get_default_category()
    sp.categories.add(get_default_category())
    sp.save()

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    # view product detail page
    url = reverse("shuup:product",
                  kwargs={
                      "pk": product.pk,
                      "slug": product.slug
                  })
    browser.visit("%s%s" % (live_server, url))
    wait_until_condition(
        browser, lambda x: x.is_text_present(product.short_description))
    assert product.description in browser.html

    # ensure the version is in static files
    assert "style.css?v=%s" % shuup.__version__ in browser.html

    # product preview
    url = reverse("shuup:xtheme_extra_view", kwargs={"view": "products"})
    browser.visit("%s%s" % (live_server, url))
    product_div_name = "product-{}".format(product.pk)
    wait_until_condition(
        browser,
        lambda x: x.find_by_css("#{} button.btn".format(product_div_name)))
    browser.execute_script(
        "$('#{} button.btn').click();".format(product_div_name))
    assert product.short_description == browser.find_by_css(
        "#{} p.description".format(product_div_name))[0].html
Exemplo n.º 11
0
def test_gdpr_consent(browser, live_server, settings):
    browser = initialize_front_browser_test(browser, live_server)

    shop = get_default_shop()
    index_url = reverse("shuup:index")

    # create a GDPR setting for the shop
    shop_gdpr = GDPRSettings.get_for_shop(shop)
    shop_gdpr.cookie_banner_content = "my cookie banner content"
    shop_gdpr.cookie_privacy_excerpt = "my cookie privacyexcerpt"
    shop_gdpr.enabled = True
    shop_gdpr.save()  # Enable GDPR

    browser.visit("%s%s" % (live_server, index_url))
    wait_until_appeared(browser, ".gdpr-consent-warn-bar")
    assert (len(browser.find_by_css(".gdpr-consent-preferences")) == 1)
    click_element(browser, "#agree-btn")

    assert len(browser.find_by_css(".gdpr-consent-warn-bar")) == 0
    assert len(browser.find_by_css(".gdpr-consent-preferences")) == 0
Exemplo n.º 12
0
def test_coupon(browser, live_server, settings):
    activate("en")
    # initialize
    cache.clear()
    shop = get_default_shop()
    get_default_payment_method()
    get_default_shipping_method()

    first_category = Category.objects.create(identifier="cat-1",
                                             status=CategoryStatus.VISIBLE,
                                             name="First Category")
    first_category.shops.add(shop)

    _populate_products_form_data(CATEGORY_PRODUCT_DATA, shop, first_category)

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    _add_product_to_basket_from_category(live_server, browser, first_category,
                                         shop)
    _activate_basket_campaign_through_coupon(browser, first_category, shop)
Exemplo n.º 13
0
def test_search_product_list(browser, live_server, settings):
    activate("en")
    # initialize
    cache.clear()
    shop = get_default_shop()

    for name, sku, price in PRODUCT_DATA:
        create_orderable_product(name, sku, price=price)

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)
    # check that front page actually loaded
    assert browser.is_text_present("Welcome to Default!")

    url = reverse("shuup:product_search")
    browser.visit("%s%s?q=test product" % (live_server, url))

    wait_until_condition(browser, lambda x: len(x.find_by_css(".product-card")) == 9)

    check_default_ordering(browser)
    # basic_sorting_test(browser)
    second_test_query(browser, live_server, url)
Exemplo n.º 14
0
def test_search_product_list(browser, live_server, settings):
    activate("en")
    # initialize
    cache.clear()
    shop = get_default_shop()

    for name, sku, price in PRODUCT_DATA:
        create_orderable_product(name, sku, price=price)

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)
    # check that front page actually loaded
    wait_until_condition(browser, lambda x: x.is_text_present("Welcome to Default!"))

    url = reverse("shuup:product_search")
    browser.visit("%s%s?q=test product" % (live_server, url))

    wait_until_condition(browser, lambda x: len(x.find_by_css(".product-card")) == 9)

    check_default_ordering(browser)
    # basic_sorting_test(browser)
    second_test_query(browser, live_server, url)
Exemplo n.º 15
0
def test_browser_checkout(browser, live_server, settings):
    # initialize
    product_name = "Test Product"
    get_default_shop()
    pm = get_default_payment_method()
    sm = get_default_shipping_method()
    product = create_orderable_product(product_name, "test-123", price=100)
    OrderStatus.objects.create(identifier="initial",
                               role=OrderStatusRole.INITIAL,
                               name="initial",
                               default=True)

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    # check that front page actually loaded
    assert browser.is_text_present("Welcome to Default!")
    assert browser.is_text_present("Newest Products")
    assert browser.is_text_present(product_name)

    browser.find_by_id("product-%s" %
                       product.pk).click()  # open product from product list
    browser.find_by_id("add-to-cart-button").click()  # add product to basket

    wait_until_appeared(browser, ".cover-wrap")
    wait_until_disappeared(browser, ".cover-wrap")

    browser.find_by_id("navigation-basket-partial").click(
    )  # open upper basket navigation menu
    browser.find_link_by_href(
        "/basket/").first.click()  # click the link to basket in dropdown
    assert browser.is_text_present("Shopping cart")  # we are in basket page
    assert browser.is_text_present(product_name)  # product is in basket

    browser.find_link_by_href(
        "/checkout/").first.click()  # click link that leads to checkout

    customer_name = "Test Tester"
    customer_street = "Test Street"
    customer_city = "Test City"
    customer_country = "US"

    # Fill all necessary information
    browser.fill("billing-name", customer_name)
    browser.fill("billing-street", customer_street)
    browser.fill("billing-city", customer_city)
    browser.select("billing-country", customer_country)

    browser.find_by_css(
        "#addresses button[type='submit']").first.click()  # click "continue"

    assert browser.is_text_present(
        "There were errors on submitted form fields. Please check them and try again."
    )

    # Fill the errors
    browser.fill("shipping-name", customer_name)
    browser.fill("shipping-street", customer_street)
    browser.fill("shipping-city", customer_city)
    browser.select("shipping-country", customer_country)

    browser.find_by_css(
        "#addresses button[type='submit']").first.click()  # click "continue"
    assert browser.is_text_present("Checkout: Shipping & Payment")

    assert browser.is_text_present(sm.name)  # shipping method name is present
    assert browser.is_text_present(pm.name)  # payment method name is present

    browser.find_by_css(".btn.btn-primary.btn-lg.pull-right").first.click(
    )  # click "continue" on methods page

    assert browser.is_text_present(
        "Checkout: Confirmation")  # we are indeed in confirmation page

    # See that all expected texts are present
    assert browser.is_text_present(product_name)
    assert browser.is_text_present(sm.name)
    assert browser.is_text_present(pm.name)
    assert browser.is_text_present("Delivery")
    assert browser.is_text_present("Billing")

    # check that user information is available
    assert browser.is_text_present(customer_name)
    assert browser.is_text_present(customer_street)
    assert browser.is_text_present(customer_city)
    assert browser.is_text_present("United States")

    browser.execute_script(
        'document.getElementById("id_accept_terms").checked=true'
    )  # click accept terms
    browser.find_by_css(
        ".btn.btn-primary.btn-lg").first.click()  # click "place order"

    browser.is_text_present("Thank you for your order!")  # order succeeded
Exemplo n.º 16
0
def test_browser_checkout_disable_methods(browser, live_server, settings,
                                          delete_method):
    # initialize
    product_name = "Test Product"
    shop = get_default_shop()

    payment_method = get_default_payment_method()
    shipping_method = get_default_shipping_method()

    product = create_orderable_product(product_name, "test-123", price=100)
    OrderStatus.objects.create(identifier="initial",
                               role=OrderStatusRole.INITIAL,
                               name="initial",
                               default=True)

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    # check that front page actually loaded
    wait_until_condition(browser,
                         lambda x: x.is_text_present("Welcome to Default!"))
    wait_until_condition(browser,
                         lambda x: x.is_text_present("Newest Products"))
    wait_until_condition(browser, lambda x: x.is_text_present(product_name))

    click_element(browser,
                  "#product-%s" % product.pk)  # open product from product list
    click_element(browser, "#add-to-cart-button-%s" %
                  product.pk)  # add product to basket

    wait_until_appeared(browser, ".cover-wrap")
    wait_until_disappeared(browser, ".cover-wrap")

    click_element(
        browser,
        "#navigation-basket-partial")  # open upper basket navigation menu
    click_element(browser,
                  "a[href='/basket/']")  # click the link to basket in dropdown
    wait_until_condition(
        browser,
        lambda x: x.is_text_present("Shopping cart"))  # we are in basket page
    wait_until_condition(
        browser,
        lambda x: x.is_text_present(product_name))  # product is in basket

    click_element(browser,
                  "a[href='/checkout/']")  # click link that leads to checkout

    customer_name = "Test Tester"
    customer_street = "Test Street"
    customer_city = "Test City"
    customer_region = "CA"
    customer_country = "US"

    # Fill all necessary information
    browser.fill("billing-name", customer_name)
    browser.fill("billing-street", customer_street)
    browser.fill("billing-city", customer_city)
    browser.select("billing-country", customer_country)
    wait_until_appeared(browser, "select[name='billing-region_code']")
    browser.select("billing-region_code", customer_region)

    browser.fill("billing-name", customer_name)
    browser.fill("billing-street", customer_street)
    browser.fill("billing-city", customer_city)
    browser.select("billing-country", customer_country)
    wait_until_appeared(browser, "select[name='billing-region_code']")
    browser.select("billing-region_code", customer_region)

    click_element(browser, "#addresses button[type='submit']"
                  )  # This shouldn't submit since missing required fields

    # Fill rest of the fields
    browser.fill("shipping-name", customer_name)
    browser.fill("shipping-street", customer_street)
    browser.fill("shipping-city", customer_city)
    browser.select("shipping-country", customer_country)

    click_element(browser, "#addresses button[type='submit']")
    wait_until_condition(
        browser, lambda x: x.is_text_present("Checkout: Shipping & Payment"))
    wait_until_condition(browser,
                         lambda x: x.is_text_present(payment_method.name))
    wait_until_condition(browser,
                         lambda x: x.is_text_present(shipping_method.name))

    browser.find_by_css("input[name='shipping_method'][value='%d']" %
                        shipping_method.pk).first.click()
    browser.find_by_css("input[name='payment_method'][value='%d']" %
                        payment_method.pk).first.click()

    click_element(browser, ".btn.btn-primary.btn-lg.pull-right"
                  )  # click "continue" on methods page
    wait_until_condition(browser, lambda x: x.is_text_present(
        "Checkout: Confirmation"))  # we are indeed in confirmation page

    if delete_method == "payment":
        payment_method.delete()
    else:
        shipping_method.delete()

    click_element(browser, "a[href='/checkout/methods/']")

    wait_until_condition(
        browser, lambda x: x.is_text_present("Checkout: Shipping & Payment"))

    if delete_method == "payment":
        wait_until_condition(
            browser, lambda x: x.is_text_present("No method is available."))
        wait_until_condition(
            browser, lambda x: not x.is_text_present(payment_method.name))
        wait_until_condition(browser,
                             lambda x: x.is_text_present(shipping_method.name))
    else:
        wait_until_condition(
            browser, lambda x: x.is_text_present("No method is available."))
        wait_until_condition(browser,
                             lambda x: x.is_text_present(payment_method.name))
        wait_until_condition(
            browser, lambda x: not x.is_text_present(shipping_method.name))
Exemplo n.º 17
0
def test_browser_checkout_vertical(browser, live_server, settings): 
    with override_settings(SHUUP_CHECKOUT_VIEW_SPEC=("shuup.front.views.checkout:SinglePageCheckoutView")):
        # initialize
        product_name = "Test Product"
        get_default_shop()
        pm = get_default_payment_method()
        sm = get_default_shipping_method()
        product = create_orderable_product(product_name, "test-123", price=100)
        OrderStatus.objects.create(
            identifier="initial",
            role=OrderStatusRole.INITIAL,
            name="initial",
            default=True
        )

        # initialize test and go to front page
        browser = initialize_front_browser_test(browser, live_server)
        # check that front page actually loaded
        wait_until_condition(browser, lambda x: x.is_text_present("Welcome to Default!"))
        wait_until_condition(browser, lambda x: x.is_text_present("Newest Products"))
        wait_until_condition(browser, lambda x: x.is_text_present(product_name))

        click_element(browser, "#product-%s" % product.pk)  # open product from product list
        click_element(browser, "#add-to-cart-button-%s" % product.pk)  # add product to basket

        wait_until_appeared(browser, ".cover-wrap")
        wait_until_disappeared(browser, ".cover-wrap")

        click_element(browser, "#navigation-basket-partial")  # open upper basket navigation menu
        click_element(browser, "a[href='/basket/']")  # click the link to basket in dropdown
        wait_until_condition(browser, lambda x: x.is_text_present("Shopping cart"))  # we are in basket page
        wait_until_condition(browser, lambda x: x.is_text_present(product_name))  # product is in basket

        click_element(browser, "a[href='/checkout/']") # click link that leads to checkout
        wait_until_appeared(browser, "h4.panel-title")
        customer_name = "Test Tester"
        customer_street = "Test Street"
        customer_city = "Test City"
        customer_region = "CA"
        customer_country = "US"

        # Fill all necessary information
        browser.fill("billing-name", customer_name)
        browser.fill("billing-street", customer_street)
        browser.fill("billing-city", customer_city)
        browser.select("billing-country", customer_country)
        wait_until_appeared(browser, "select[name='billing-region_code']")
        browser.select("billing-region_code", customer_region)

        click_element(browser, "#addresses button[type='submit']")

        wait_until_condition(browser, lambda x: x.is_text_present("This field is required."))

        # Fill the errors
        browser.fill("shipping-name", customer_name)
        browser.fill("shipping-street", customer_street)
        browser.fill("shipping-city", customer_city)
        browser.select("shipping-country", customer_country)

        click_element(browser, "#addresses button[type='submit']")
        wait_until_condition(browser, lambda x: x.is_text_present("Shipping & Payment"))

        wait_until_condition(browser, lambda x: x.is_text_present(sm.name))  # shipping method name is present
        wait_until_condition(browser, lambda x: x.is_text_present(pm.name))  # payment method name is present

        click_element(browser, ".btn.btn-primary.btn-lg.pull-right")  # click "continue" on methods page

        wait_until_condition(browser, lambda x: x.is_text_present("Confirmation"))  # we are indeed in confirmation page

        # See that all expected texts are present
        wait_until_condition(browser, lambda x: x.is_text_present(product_name))
        wait_until_condition(browser, lambda x: x.is_text_present(sm.name))
        wait_until_condition(browser, lambda x: x.is_text_present(pm.name))
        wait_until_condition(browser, lambda x: x.is_text_present("Delivery"))
        wait_until_condition(browser, lambda x: x.is_text_present("Billing"))

        # check that user information is available
        wait_until_condition(browser, lambda x: x.is_text_present(customer_name))
        wait_until_condition(browser, lambda x: x.is_text_present(customer_street))
        wait_until_condition(browser, lambda x: x.is_text_present(customer_city))
        wait_until_condition(browser, lambda x: x.is_text_present("United States"))

        browser.execute_script('document.getElementById("id_accept_terms").checked=true')  # click accept terms
        click_element(browser, ".btn.btn-primary.btn-lg")  # click "place order"

        wait_until_condition(browser, lambda x: x.is_text_present("Thank you for your order!"))  # order succeeded
Exemplo n.º 18
0
def test_category_product_list(browser, live_server, settings):
    activate("en")
    # initialize
    cache.clear()
    shop = get_default_shop()

    for name, identifier in CATEGORY_DATA:
        category = Category()
        category.name = name
        category.identifier = identifier
        category.status = CategoryStatus.VISIBLE
        category.save()
        category.shops.add(shop)

    for name, identifier in MANUFACTURER_DATA:
        Manufacturer.objects.create(name=name, identifier=identifier)

    first_cat = Category.objects.filter(identifier="cat-1").first()
    second_cat = Category.objects.filter(identifier="cat-2").first()
    third_cat = Category.objects.filter(identifier="cat-3").first()
    assert first_cat.pk != second_cat.pk
    for name, sku, price in FIRST_CATEGORY_PRODUCT_DATA:
        product = create_orderable_product(name, sku, price=price)
        shop_product = product.get_shop_instance(shop)
        cat = Category.objects.first()
        shop_product.primary_category = first_cat
        shop_product.save()
        shop_product.categories.add(first_cat)

    # Add some variation products
    add_variations(shop,
                   Product.objects.filter(sku="test-sku-1").first(),
                   ["Black", "Yellow"], ["Big", "Small"])

    add_variations(shop,
                   Product.objects.filter(sku="test-sku-2").first(),
                   ["Brown", "Pink"], ["S", "L", "XL"])

    add_variations(shop,
                   Product.objects.filter(sku="test-sku-3").first(),
                   ["Brown", "Black"], ["S", "L", "XL", "Big"])

    for i in range(1, 14):
        product = create_orderable_product("Test product",
                                           "sku-%s" % i,
                                           price=i)
        shop_product = product.get_shop_instance(shop)
        cat = Category.objects.first()
        shop_product.primary_category = second_cat
        shop_product.save()
        shop_product.categories.add(second_cat)

    # Set manufacturer for first product only
    first_manufacturer = Manufacturer.objects.first()
    Product.objects.filter(sku="test-sku-1").update(
        manufacturer_id=first_manufacturer.id)

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    # check that front page actually loaded
    assert browser.is_text_present("Welcome to Default!")

    url = reverse("shuup:category",
                  kwargs={
                      "pk": first_cat.pk,
                      "slug": first_cat.slug
                  })
    browser.visit("%s%s" % (live_server, url))
    assert browser.is_text_present("First Category")
    assert browser.is_text_present("Sort")
    assert not browser.is_text_present(
        "Manufacturers")  # Since not in default configuration
    hide_sorts_for_shop(browser, shop)
    show_sorts_for_the_category_only(browser, first_cat)

    # All sorts for first_cat is available test sorting
    sort_category_products_test(browser, first_cat)

    manufacturer_filter_test(browser, first_cat, first_manufacturer)
    variations_filter_test(browser, first_cat)
    categories_filter_test(browser, first_cat, second_cat, third_cat)

    second_category_sort_test(browser, live_server, shop, second_cat)
    second_category_sort_with_price_filter(browser, second_cat)
Exemplo n.º 19
0
def test_browser_checkout_horizontal(browser, live_server, settings):
    # initialize
    product_name = "Test Product"
    get_default_shop()
    pm = get_default_payment_method()
    sm = get_default_shipping_method()
    product = create_orderable_product(product_name, "test-123", price=100)
    OrderStatus.objects.create(identifier="initial",
                               role=OrderStatusRole.INITIAL,
                               name="initial",
                               default=True)

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    # check that front page actually loaded
    wait_until_condition(browser,
                         lambda x: x.is_text_present("Welcome to Default!"))
    wait_until_condition(browser,
                         lambda x: x.is_text_present("Newest Products"))
    wait_until_condition(browser, lambda x: x.is_text_present(product_name))

    click_element(browser,
                  "#product-%s" % product.pk)  # open product from product list
    click_element(browser, "#add-to-cart-button-%s" %
                  product.pk)  # add product to basket

    wait_until_appeared(browser, ".cover-wrap")
    wait_until_disappeared(browser, ".cover-wrap")

    click_element(
        browser,
        "#navigation-basket-partial")  # open upper basket navigation menu
    click_element(browser,
                  "a[href='/basket/']")  # click the link to basket in dropdown
    wait_until_condition(
        browser,
        lambda x: x.is_text_present("Shopping cart"))  # we are in basket page
    wait_until_condition(
        browser,
        lambda x: x.is_text_present(product_name))  # product is in basket

    click_element(browser,
                  "a[href='/checkout/']")  # click link that leads to checkout

    customer_name = "Test Tester"
    customer_street = "Test Street"
    customer_city = "Test City"
    customer_region = "CA"
    customer_country = "US"

    # Fill all necessary information
    browser.fill("billing-name", customer_name)
    browser.fill("billing-street", customer_street)
    browser.fill("billing-city", customer_city)
    browser.select("billing-country", customer_country)
    wait_until_appeared(browser, "select[name='billing-region_code']")
    browser.select("billing-region_code", customer_region)

    click_element(browser, "#addresses button[type='submit']"
                  )  # This shouldn't submit since missing required fields

    # Fill rest of the fields
    browser.fill("shipping-name", customer_name)
    browser.fill("shipping-street", customer_street)
    browser.fill("shipping-city", customer_city)
    browser.select("shipping-country", customer_country)

    click_element(browser, "#addresses button[type='submit']")
    wait_until_condition(
        browser, lambda x: x.is_text_present("Checkout: Shipping & Payment"))

    wait_until_condition(browser, lambda x: x.is_text_present(sm.name)
                         )  # shipping method name is present
    wait_until_condition(
        browser,
        lambda x: x.is_text_present(pm.name))  # payment method name is present

    click_element(browser, ".btn.btn-primary.btn-lg.pull-right"
                  )  # click "continue" on methods page

    wait_until_condition(browser, lambda x: x.is_text_present(
        "Checkout: Confirmation"))  # we are indeed in confirmation page

    # See that all expected texts are present
    wait_until_condition(browser, lambda x: x.is_text_present(product_name))
    wait_until_condition(browser, lambda x: x.is_text_present(sm.name))
    wait_until_condition(browser, lambda x: x.is_text_present(pm.name))
    wait_until_condition(browser, lambda x: x.is_text_present("Delivery"))
    wait_until_condition(browser, lambda x: x.is_text_present("Billing"))

    # check that user information is available
    wait_until_condition(browser, lambda x: x.is_text_present(customer_name))
    wait_until_condition(browser, lambda x: x.is_text_present(customer_street))
    wait_until_condition(browser, lambda x: x.is_text_present(customer_city))
    wait_until_condition(browser, lambda x: x.is_text_present("United States"))

    browser.execute_script(
        'document.getElementById("id_accept_terms").checked=true'
    )  # click accept terms
    click_element(browser, ".btn.btn-primary.btn-lg")  # click "place order"

    wait_until_condition(browser, lambda x: x.is_text_present(
        "Thank you for your order!"))  # order succeeded
Exemplo n.º 20
0
def test_browser_checkout(browser, live_server, settings):
    # initialize
    product_name = "Test Product"
    get_default_shop()
    pm = get_default_payment_method()
    sm = get_default_shipping_method()
    product = create_orderable_product(product_name, "test-123", price=100)
    OrderStatus.objects.create(
        identifier="initial",
        role=OrderStatusRole.INITIAL,
        name="initial",
        default=True
    )

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    # check that front page actually loaded
    assert browser.is_text_present("Welcome to Default!")
    assert browser.is_text_present("Newest Products")
    assert browser.is_text_present(product_name)

    click_element(browser, "#product-%s" % product.pk)  # open product from product list
    click_element(browser, "#add-to-cart-button")  # add product to basket

    wait_until_appeared(browser, ".cover-wrap")
    wait_until_disappeared(browser, ".cover-wrap")

    click_element(browser, "#navigation-basket-partial")  # open upper basket navigation menu
    click_element(browser, "a[href='/basket/']")  # click the link to basket in dropdown
    assert browser.is_text_present("Shopping cart")  # we are in basket page
    assert browser.is_text_present(product_name)  # product is in basket

    click_element(browser, "a[href='/checkout/']") # click link that leads to checkout

    customer_name = "Test Tester"
    customer_street = "Test Street"
    customer_city = "Test City"
    customer_country = "US"

    # Fill all necessary information
    browser.fill("billing-name", customer_name)
    browser.fill("billing-street", customer_street)
    browser.fill("billing-city", customer_city)
    browser.select("billing-country", customer_country)

    click_element(browser, "#addresses button[type='submit']")

    assert browser.is_text_present("There were errors on submitted form fields. Please check them and try again.")

    # Fill the errors
    browser.fill("shipping-name", customer_name)
    browser.fill("shipping-street", customer_street)
    browser.fill("shipping-city", customer_city)
    browser.select("shipping-country", customer_country)

    click_element(browser, "#addresses button[type='submit']")
    assert browser.is_text_present("Checkout: Shipping & Payment")

    assert browser.is_text_present(sm.name)  # shipping method name is present
    assert browser.is_text_present(pm.name)  # payment method name is present

    click_element(browser, ".btn.btn-primary.btn-lg.pull-right")  # click "continue" on methods page

    assert browser.is_text_present("Checkout: Confirmation")  # we are indeed in confirmation page

    # See that all expected texts are present
    assert browser.is_text_present(product_name)
    assert browser.is_text_present(sm.name)
    assert browser.is_text_present(pm.name)
    assert browser.is_text_present("Delivery")
    assert browser.is_text_present("Billing")

    # check that user information is available
    assert browser.is_text_present(customer_name)
    assert browser.is_text_present(customer_street)
    assert browser.is_text_present(customer_city)
    assert browser.is_text_present("United States")

    browser.execute_script('document.getElementById("id_accept_terms").checked=true')  # click accept terms
    click_element(browser, ".btn.btn-primary.btn-lg")  # click "place order"

    assert browser.is_text_present("Thank you for your order!")  # order succeeded
Exemplo n.º 21
0
def test_category_product_list(browser, live_server, settings):
    activate("en")
    # initialize
    cache.clear()
    shop = get_default_shop()

    for name, identifier in CATEGORY_DATA:
        category = Category()
        category.name = name
        category.identifier = identifier
        category.status = CategoryStatus.VISIBLE
        category.save()
        category.shops.add(shop)

    for name, identifier in MANUFACTURER_DATA:
        Manufacturer.objects.create(name=name, identifier=identifier)

    first_cat = Category.objects.filter(identifier="cat-1").first()
    second_cat = Category.objects.filter(identifier="cat-2").first()
    third_cat = Category.objects.filter(identifier="cat-3").first()
    assert first_cat.pk != second_cat.pk
    for name, sku, price in FIRST_CATEGORY_PRODUCT_DATA:
        product = create_orderable_product(name, sku, price=price)
        shop_product = product.get_shop_instance(shop)
        cat = Category.objects.first()
        shop_product.primary_category = first_cat
        shop_product.save()
        shop_product.categories.add(first_cat)

    # Add some variation products
    add_variations(
        shop, Product.objects.filter(sku="test-sku-1").first(),
        ["Black", "Yellow"], ["Big", "Small"]
    )

    add_variations(
        shop, Product.objects.filter(sku="test-sku-2").first(),
        ["Brown", "Pink"], ["S", "L", "XL"]
    )

    add_variations(
        shop, Product.objects.filter(sku="test-sku-3").first(),
        ["Brown", "Black"], ["S", "L", "XL", "Big"]
    )

    for i in range(1, 14):
        product = create_orderable_product("Test product", "sku-%s" % i, price=i)
        shop_product = product.get_shop_instance(shop)
        cat = Category.objects.first()
        shop_product.primary_category = second_cat
        shop_product.save()
        shop_product.categories.add(second_cat)


    # Set manufacturer for first product only
    first_manufacturer = Manufacturer.objects.first()
    Product.objects.filter(sku="test-sku-1").update(manufacturer_id=first_manufacturer.id)

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    # check that front page actually loaded
    wait_until_condition(browser, lambda x: x.is_text_present("Welcome to Default!"))

    url = reverse("shuup:category", kwargs={"pk": first_cat.pk, "slug": first_cat.slug})
    browser.visit("%s%s" % (live_server, url))
    wait_until_condition(browser, lambda x: x.is_text_present("First Category"))
    wait_until_condition(browser, lambda x: x.is_text_present("Sort"))
    assert not browser.is_text_present("Manufacturers")  # Since not in default configuration
    hide_sorts_for_shop(browser, shop)
    show_sorts_for_the_category_only(browser, first_cat)

    # All sorts for first_cat is available test sorting
    sort_category_products_test(browser, first_cat)

    manufacturer_filter_test(browser, first_cat, first_manufacturer)
    variations_filter_test(browser, first_cat)
    categories_filter_test(browser, first_cat, second_cat, third_cat)

    second_category_sort_test(browser, live_server, shop, second_cat)
    second_category_sort_with_price_filter(browser, second_cat)
Exemplo n.º 22
0
def test_browser_checkout_addresses_vertical(browser, live_server, settings):
    with override_settings(SHUUP_CHECKOUT_VIEW_SPEC=(
            "shuup.front.views.checkout:SinglePageCheckoutView")):
        # initialize
        product_name = "Test Product"
        get_default_shop()
        pm = get_default_payment_method()
        sm = get_default_shipping_method()
        product = create_orderable_product(product_name, "test-123", price=100)
        OrderStatus.objects.create(identifier="initial",
                                   role=OrderStatusRole.INITIAL,
                                   name="initial",
                                   default=True)

        # initialize test and go to front page
        browser = initialize_front_browser_test(browser, live_server)
        # check that front page actually loaded
        wait_until_condition(
            browser, lambda x: x.is_text_present("Welcome to Default!"))
        wait_until_condition(browser,
                             lambda x: x.is_text_present("Newest Products"))
        wait_until_condition(browser,
                             lambda x: x.is_text_present(product_name))

        click_element(browser, "#product-%s" %
                      product.pk)  # open product from product list
        click_element(browser, "#add-to-cart-button-%s" %
                      product.pk)  # add product to basket

        wait_until_appeared(browser, ".cover-wrap")
        wait_until_disappeared(browser, ".cover-wrap")

        click_element(
            browser,
            "#navigation-basket-partial")  # open upper basket navigation menu
        click_element(
            browser,
            "a[href='/basket/']")  # click the link to basket in dropdown
        wait_until_condition(browser, lambda x: x.is_text_present(
            "Shopping cart"))  # we are in basket page
        wait_until_condition(
            browser,
            lambda x: x.is_text_present(product_name))  # product is in basket

        click_element(
            browser,
            "a[href='/checkout/']")  # click link that leads to checkout
        wait_until_appeared(browser, "h4.panel-title")

        customer_name = "Test Tester"
        customer_street = "Test Street"

        customer_city1 = "Los Angeles"
        customer_city2 = "Chiedo"

        customer_region1 = "CA"
        customer_region2 = "My Region Name"

        customer_country1 = "US"
        customer_country2 = "AR"  # Doesn't have region codes

        # Fill all billing address fields with USA address
        browser.fill("billing-name", customer_name)
        browser.fill("billing-street", customer_street)
        browser.fill("billing-city", customer_city1)
        browser.select("billing-country", customer_country1)
        wait_until_appeared(browser, "select[name='billing-region_code']")
        browser.select("billing-region_code", customer_region1)

        # Click to send to billing address (copy billing to shipping)
        browser.find_by_css("label[for='same_as_billing']").first.click()

        # continue
        click_element(browser, "#addresses button[type='submit']")

        wait_until_condition(browser,
                             lambda x: x.is_text_present("Shipping & Payment"))
        # continue on methods page
        click_element(browser, ".btn.btn-primary.btn-lg.pull-right")
        wait_until_condition(browser,
                             lambda x: x.is_text_present("Confirmation"))

        # See that all expected texts are present
        wait_until_condition(browser,
                             lambda x: x.is_text_present(customer_name))
        wait_until_condition(browser,
                             lambda x: x.is_text_present(customer_street))
        wait_until_condition(browser,
                             lambda x: x.is_text_present(customer_city1))
        wait_until_condition(browser,
                             lambda x: x.is_text_present("United States"))

        # back to address phase, we want to send to Argentina
        browser.find_by_css("a[data-phase='addresses']").first.click()

        # all values must be there with correct saved values
        billing_country = browser.find_by_name("billing-country").first
        wait_until_appeared(browser, "select[name='billing-region_code']")
        billing_region_code = browser.find_by_name("billing-region_code").first
        shipping_country = browser.find_by_name("shipping-country").first
        wait_until_appeared(browser, "select[name='shipping-region_code']")
        shipping_region_code = browser.find_by_name(
            "shipping-region_code").first
        assert billing_country.value == customer_country1
        assert billing_region_code.value == customer_region1
        assert shipping_country.value == customer_country1
        assert shipping_region_code.value == customer_region1

        # same_as_billing is not checked
        assert not browser.find_by_css(
            "label[for='same_as_billing']").first.checked

        # click on same as billing twice, so we copy and clean the field, just to try messing
        browser.find_by_css("label[for='same_as_billing']").first.click()
        browser.find_by_css("label[for='same_as_billing']").first.click()

        # region field should be enabled
        wait_until_condition(
            browser, lambda x: not x.find_by_name("shipping-region_code").
            has_class("disabled"))

        # Fill all shipping address fields - Argentina address
        browser.fill("shipping-name", customer_name)
        browser.fill("shipping-street", customer_street)
        browser.fill("shipping-city", customer_city2)
        browser.select("shipping-country", customer_country2)
        browser.fill("shipping-region", customer_region2)

        # continue
        click_element(browser, "#addresses button[type='submit']")
        wait_until_condition(browser,
                             lambda x: x.is_text_present("Shipping & Payment"))
        # continue
        click_element(browser, ".btn.btn-primary.btn-lg.pull-right")
        wait_until_condition(browser,
                             lambda x: x.is_text_present("Confirmation"))

        wait_until_condition(browser,
                             lambda x: x.is_text_present(customer_name))
        wait_until_condition(browser,
                             lambda x: x.is_text_present(customer_street))
        wait_until_condition(browser,
                             lambda x: x.is_text_present(customer_city1))
        wait_until_condition(browser,
                             lambda x: x.is_text_present(customer_city2))
        wait_until_condition(browser,
                             lambda x: x.is_text_present(customer_region1))
        wait_until_condition(browser,
                             lambda x: x.is_text_present(customer_region2))
        wait_until_condition(browser, lambda x: x.is_text_present("Argentina"))
        wait_until_condition(browser,
                             lambda x: x.is_text_present("United States"))

        browser.execute_script(
            'document.getElementById("id_accept_terms").checked=true'
        )  # click accept terms
        click_element(browser,
                      ".btn.btn-primary.btn-lg")  # click "place order"

        wait_until_condition(browser, lambda x: x.is_text_present(
            "Thank you for your order!"))  # order succeeded
Exemplo n.º 23
0
def test_browser_checkout_addresses_horizontal(browser, live_server, settings):
    # initialize
    product_name = "Test Product"
    get_default_shop()
    pm = get_default_payment_method()
    sm = get_default_shipping_method()
    product = create_orderable_product(product_name, "test-123", price=100)
    OrderStatus.objects.create(identifier="initial",
                               role=OrderStatusRole.INITIAL,
                               name="initial",
                               default=True)

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    # check that front page actually loaded
    wait_until_condition(browser,
                         lambda x: x.is_text_present("Welcome to Default!"))
    wait_until_condition(browser,
                         lambda x: x.is_text_present("Newest Products"))
    wait_until_condition(browser, lambda x: x.is_text_present(product_name))

    click_element(browser,
                  "#product-%s" % product.pk)  # open product from product list
    click_element(browser, "#add-to-cart-button-%s" %
                  product.pk)  # add product to basket
    wait_until_appeared(browser, ".cover-wrap")
    wait_until_disappeared(browser, ".cover-wrap")

    click_element(
        browser,
        "#navigation-basket-partial")  # open upper basket navigation menu
    click_element(browser,
                  "a[href='/basket/']")  # click the link to basket in dropdown
    wait_until_condition(
        browser,
        lambda x: x.is_text_present("Shopping cart"))  # we are in basket page
    wait_until_condition(
        browser,
        lambda x: x.is_text_present(product_name))  # product is in basket

    click_element(browser,
                  "a[href='/checkout/']")  # click link that leads to checkout

    customer_name = "Test Tester"
    customer_street = "Test Street"

    customer_city1 = "Los Angeles"
    customer_city2 = "Blumenau"
    customer_city3 = "Vancouver"

    customer_region1 = "CA"
    customer_region2 = "SC"
    customer_region3 = "BC"

    customer_country1 = "US"
    customer_country2 = "BR"
    customer_country3 = "CA"

    # Fill all billing address fields with USA address
    browser.fill("billing-name", customer_name)
    browser.fill("billing-street", customer_street)
    browser.fill("billing-city", customer_city1)
    browser.select("billing-country", customer_country1)
    wait_until_appeared(browser, "select[name='billing-region_code']")
    browser.select("billing-region_code", customer_region1)

    # Fill all shipping address fields - Brazil address
    browser.fill("shipping-name", customer_name)
    browser.fill("shipping-street", customer_street)
    browser.fill("shipping-city", customer_city2)
    browser.select("shipping-country", customer_country2)
    wait_until_appeared(browser, "select[name='shipping-region_code']")
    browser.select("shipping-region_code", customer_region2)

    # Actually, click to send to billing address (copy billing to shipping)
    browser.find_by_css("label[for='same_as_billing']").first.click()

    # check whether fields are disable and the values are equals
    wait_until_condition(
        browser,
        lambda x: x.find_by_name("shipping-region_code").has_class("disabled"))
    wait_until_condition(
        browser,
        lambda x: x.find_by_name("shipping-country").has_class("disabled"))
    billing_country = browser.find_by_name("billing-country").first
    shipping_country = browser.find_by_name("shipping-country").first
    wait_until_appeared(browser, "select[name='billing-region_code']")
    wait_until_appeared(browser, "select[name='shipping-region_code']")
    billing_region_code = browser.find_by_name("billing-region_code").first
    shipping_region_code = browser.find_by_name("shipping-region_code").first
    assert billing_country.value == shipping_country.value
    assert billing_region_code.value == shipping_region_code.value

    # Actually, send to Canada
    browser.find_by_css("label[for='same_as_billing']").first.click()
    wait_until_condition(
        browser, lambda x: not x.find_by_name("shipping-region_code").
        has_class("disabled"))
    wait_until_condition(
        browser,
        lambda x: not x.find_by_name("shipping-country").has_class("disabled"))
    browser.fill("shipping-city", customer_city3)
    browser.select("shipping-country", customer_country3)
    wait_until_appeared(browser, "select[name='shipping-region_code']")
    browser.select("shipping-region_code", customer_region3)

    # continue
    click_element(browser, "#addresses button[type='submit']")

    wait_until_condition(
        browser, lambda x: x.is_text_present("Checkout: Shipping & Payment"))
    wait_until_condition(browser, lambda x: x.is_text_present(sm.name)
                         )  # shipping method name is present
    wait_until_condition(
        browser,
        lambda x: x.is_text_present(pm.name))  # payment method name is present

    # back to address phase, we want to send to Brazil nstead
    address_link = browser.find_by_text('1. Addresses')
    address_link.click()

    # all values must be there with correct saved values
    billing_country = browser.find_by_name("billing-country").first
    wait_until_appeared(browser, "select[name='billing-region_code']")
    billing_region_code = browser.find_by_name("billing-region_code").first
    shipping_country = browser.find_by_name("shipping-country").first
    wait_until_appeared(browser, "select[name='shipping-region_code']")
    shipping_region_code = browser.find_by_name("shipping-region_code").first
    assert billing_country.value == customer_country1
    assert billing_region_code.value == customer_region1
    assert shipping_country.value == customer_country3
    assert shipping_region_code.value == customer_region3

    # Fill shipping with Brazil and Billing with Canada
    browser.fill("shipping-city", customer_city2)
    browser.select("shipping-country", customer_country2)
    wait_until_appeared(browser, "select[name='shipping-region_code']")
    browser.select("shipping-region_code", customer_region2)

    browser.fill("billing-city", customer_city3)
    browser.select("billing-country", customer_country3)
    wait_until_appeared(browser, "select[name='billing-region_code']")
    browser.select("billing-region_code", customer_region3)

    # continue
    click_element(browser, "#addresses button[type='submit']")
    wait_until_condition(
        browser, lambda x: x.is_text_present("Checkout: Shipping & Payment"))

    click_element(browser, ".btn.btn-primary.btn-lg.pull-right"
                  )  # click "continue" on methods page
    wait_until_condition(browser, lambda x: x.is_text_present(
        "Checkout: Confirmation"))  # we are indeed in confirmation page

    # See that all expected texts are present
    wait_until_condition(browser, lambda x: x.is_text_present(product_name))
    wait_until_condition(browser, lambda x: x.is_text_present(sm.name))
    wait_until_condition(browser, lambda x: x.is_text_present(pm.name))
    wait_until_condition(browser, lambda x: x.is_text_present("Delivery"))
    wait_until_condition(browser, lambda x: x.is_text_present("Billing"))
    # check that user information is available
    wait_until_condition(browser, lambda x: x.is_text_present(customer_name))
    wait_until_condition(browser, lambda x: x.is_text_present(customer_street))
    wait_until_condition(browser, lambda x: x.is_text_present(customer_city2))
    wait_until_condition(browser, lambda x: x.is_text_present(customer_city3))
    wait_until_condition(browser, lambda x: x.is_text_present("Canada"))
    wait_until_condition(browser, lambda x: x.is_text_present("Brazil"))

    browser.execute_script(
        'document.getElementById("id_accept_terms").checked=true'
    )  # click accept terms
    click_element(browser, ".btn.btn-primary.btn-lg")
    wait_until_condition(
        browser, lambda x: x.is_text_present("Thank you for your order!"))