def _add_product_to_basket_from_category(live_server, browser, first_category, shop): url = reverse("shuup:category", kwargs={"pk": first_category.pk, "slug": first_category.slug}) browser.visit("%s%s" % (live_server, url)) wait_until_condition(browser, lambda x: x.is_text_present(first_category.name)) # Make sure that the correct price is visible product = Product.objects.filter(sku="test-sku-2").first() selector = "#product-%s div.price-line span.lead strong" % product.id wait_until_condition(browser, lambda x: "720" in x.find_by_css(selector).first.text) # Test product price update new_price = 42 shop_product = product.get_shop_instance(shop) shop_product.default_price_value = new_price shop_product.save() discount_amount = 5 _create_category_product_discount(first_category, shop, discount_amount) browser.reload() wait_until_condition( browser, lambda x: str(new_price - discount_amount) in x.find_by_css(selector).first.text ) # Go to product detail and update the price one more time click_element(browser, selector) product_detail_price_selector = "#product-price-div-%s span.product-price strong" % product.id wait_until_appeared(browser, product_detail_price_selector) wait_until_condition( browser, lambda x: str(new_price - discount_amount) in x.find_by_css(product_detail_price_selector).first.text) last_price = 120.53 shop_product = product.get_shop_instance(shop) shop_product.default_price_value = last_price shop_product.save() new_discount_amount = 10 _create_category_product_discount(first_category, shop, new_discount_amount) browser.reload() wait_until_condition( browser, lambda x: str(last_price - new_discount_amount) in x.find_by_css(product_detail_price_selector).first.text ) # Add product to basket and navigate to basket view 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
def navigate_to_checkout(browser, product): 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
def register_test(browser, live_server, test_username, test_email, test_password): click_element(browser, "button[data-id='id_checkout_method_choice-register']") click_element(browser, "li[data-original-index='1'] a") click_element(browser, "div.clearfix button.btn.btn-primary.btn-lg.pull-right") wait_until_condition(browser, lambda x: x.is_text_present("Register")) browser.find_by_id("id_username").fill(test_username) browser.find_by_id("id_email").fill(test_email) browser.find_by_id("id_password1").fill(test_password) browser.find_by_id("id_password2").fill("typo-%s" % test_password) click_element(browser, "div.clearfix button.btn.btn-primary.btn-lg.pull-right") wait_until_appeared(browser, "div.form-group.passwordinput.required.has-error") browser.find_by_id("id_password1").fill(test_password) browser.find_by_id("id_password2").fill(test_password) click_element(browser, "div.clearfix button.btn.btn-primary.btn-lg.pull-right") wait_until_condition(browser, lambda x: x.is_text_present("Addresses")) # Reload here just in case since there might have been reload with JS # which might cause issues with tests since the elements is in cache browser.reload() # Log out and go back to checkout choice phase click_element(browser, "div.top-nav i.menu-icon.fa.fa-user") click_element(browser, "a[href='/logout/']") # Ensure that the language is still english. It seems that the language might change # during the logout. browser.find_by_id("language-changer").click() browser.find_by_xpath('//a[@class="language"]').first.click() # There is no products on basket anymore so let's add one product = Product.objects.first() product_url = reverse("shuup:product", kwargs={"pk": product.pk, "slug": product.slug}) browser.visit("%s%s" % (live_server, product_url)) 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") browser.visit("%s%s" % (live_server, "/checkout/"))
def login_and_finish_up_the_checkout(browser, live_server, test_username, test_email, test_password): browser.fill("login-username", test_email) browser.fill("login-password", test_password) click_element(browser, "button[name='login']") wait_until_condition(browser, lambda x: x.is_text_present("Addresses"), timeout=100) # Reload here just in case since there might have been reload with JS # which might cause issues with tests since the elements is in cache browser.reload() # This should be first order upcoming assert Order.objects.count() == 0 # Fnish the 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) wait_until_appeared(browser, "#id_billing-region") browser.select("billing-country", customer_country) wait_until_disappeared(browser, "#id_billing-region") 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.")) browser.fill("shipping-name", customer_name) browser.fill("shipping-street", customer_street) browser.fill("shipping-city", customer_city) wait_until_appeared(browser, "#id_shipping-region") browser.select("shipping-country", customer_country) wait_until_disappeared(browser, "#id_shipping-region") wait_until_appeared(browser, "select[name='shipping-region_code']") click_element(browser, "#addresses button[type='submit']") wait_until_condition(browser, lambda x: x.is_text_present("Shipping & Payment")) pm = get_default_payment_method() sm = get_default_shipping_method() 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 product = Product.objects.first() # 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 # Let's make sure the order now has a customer assert Order.objects.count() == 1 order = Order.objects.first() assert order.customer == PersonContact.objects.filter(user__username=test_username).first() assert order.customer.name == customer_name assert order.customer.default_shipping_address is not None assert order.customer.default_billing_address is not None assert order.customer.user.username == test_username
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
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!"))
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
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