本文整理汇总了Python中shuup.testing.browser_utils.wait_until_condition函数的典型用法代码示例。如果您正苦于以下问题:Python wait_until_condition函数的具体用法?Python wait_until_condition怎么用?Python wait_until_condition使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wait_until_condition函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _set_settings
def _set_settings(browser):
assert not browser.is_text_present("Account Manager")
browser.find_by_css(".btn.btn-default.btn-inverse").click()
browser.find_by_css(".btn.btn-xs.btn-success.btn-add-sortable").first.click()
browser.find_by_css(".btn.btn-success").first.click()
wait_until_appeared(browser, ".picotable-item-info")
wait_until_condition(browser, lambda x: x.is_text_present("Account Manager"))
示例2: _test_customer_data
def _test_customer_data(browser, person):
# check defaults
assert browser.find_by_css("input[name='save-address']").first.checked == True
assert browser.find_by_css("input[name='ship-to-billing-address']").first.checked == False
assert browser.find_by_css("input[name='order-for-company']").first.checked == False
assert not browser.find_by_css("input[name='billing-tax_number']").first['required']
browser.check("ship-to-billing-address")
browser.check("order-for-company")
assert len(browser.find_by_css("input[name='shipping-name']")) == 0, "shipping address column is hidden"
assert browser.find_by_css("input[name='billing-tax_number']").first['required'], "tax number is required"
browser.uncheck("order-for-company")
click_element(browser, "#select-existing-customer")
browser.windows.current = browser.windows[1]
wait_until_appeared(browser, "a")
# click second row - first row is admin
browser.find_by_css("tbody tr")[1].find_by_css("a").click()
browser.windows.current = browser.windows[0]
# check fields were set
wait_until_condition(
browser, lambda x: x.find_by_name("billing-name").value == person.name)
assert browser.find_by_name("billing-name").value == person.name
assert browser.find_by_name("billing-street").value == person.default_billing_address.street
assert browser.find_by_name("billing-city").value == person.default_billing_address.city
assert browser.find_by_name("billing-country").value == person.default_billing_address.country
示例3: test_product_descriptions
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
示例4: _test_quick_add_lines
def _test_quick_add_lines(browser):
assert browser.find_by_css("input[name='auto-add']").first.checked == True
# add line automatically just by searching and finding direct match
click_element(browser, "#quick-add .select2")
wait_until_condition(
browser, lambda x: len(browser.find_by_css("#quick-add .select2-container--open")) == 1)
browser.find_by_css("input.select2-search__field").first.value = "test-sku1"
wait_until_condition(browser, lambda x: len(x.find_by_css("#lines .list-group-item")) == 1)
line_items = browser.find_by_css("#lines .list-group-item")
assert len(browser.find_by_css("#quick-add .select2-container--open")) == 1, "select is open after add"
assert line_items.first.find_by_css('input[name="quantity"]').first.value == '1', "one piece added"
browser.find_by_css("input.select2-search__field").first.value = "test-sku1"
wait_until_condition(browser, lambda x: x.find_by_css('#lines input[name="quantity"]').first.value == '2')
line_items = browser.find_by_id("lines").find_by_css('.list-group-item')
assert len(line_items) == 1, "only one line item exists"
assert line_items.first.find_by_css('input[name="quantity"]').first.value == '2', "two pieces added"
# add line automatically by searching and clicking on match
browser.find_by_css("input.select2-search__field").first.value = "test-sku"
wait_until_appeared(browser, ".select2-results__option:not([aria-live='assertive'])")
browser.execute_script('$($(".select2-results__option")[0]).trigger({type: "mouseup"})')
wait_until_condition(browser, lambda x: x.find_by_css('#lines input[name="quantity"]').first.value == '3')
assert line_items.first.find_by_css('input[name="quantity"]').first.value == '3', "three pieces added"
# add line manually
browser.uncheck("auto-add")
click_element(browser, "#quick-add .select2")
wait_until_appeared(browser, "input.select2-search__field")
browser.find_by_css("input.select2-search__field").first.value = "test-sku0"
wait_until_appeared(browser, ".select2-results__option:not([aria-live='assertive'])")
browser.execute_script('$($(".select2-results__option")[0]).trigger({type: "mouseup"})')
wait_until_condition(browser, lambda x: len(x.find_by_css('#lines .list-group-item')) == 2)
line_items = browser.find_by_id("lines").find_by_css('.list-group-item')
assert len(line_items) == 2, "two line items exist"
示例5: test_single_page_checkout_with_login_and_register
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_username"
test_email = "[email protected]"
test_password = "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)
示例6: set_status
def set_status(browser, order, status):
click_element(browser, "button.set-status-button")
form_action = reverse("shuup_admin:order.set-status", kwargs={"pk": order.pk})
click_element(browser, "button[formaction='%s'][value='%s']" % (form_action, status.pk))
wait_until_appeared(browser, "div[class='message success']")
wait_until_condition(browser, condition=lambda x: x.is_text_present("Order %s" % order.pk))
order.refresh_from_db()
assert order.status.pk == status.pk
示例7: test_xtheme_snippet_injection
def test_xtheme_snippet_injection(browser, admin_user, live_server, settings):
shop = factories.get_default_shop()
initialize_admin_browser_test(browser, live_server, settings)
url = reverse("shuup_admin:xtheme_snippet.new")
browser.visit("%s%s" % (live_server, url))
wait_until_condition(browser, lambda x: x.is_text_present("New Snippet"))
browser.execute_script("$(\"[name='location']\").val('body_end').trigger('change')")
browser.execute_script("$(\"[name='snippet_type']\").val('inline_js').trigger('change')")
browser.execute_script("window.CodeMirror.editors['id_snippet-snippet'].setValue('alert(\"works\")');")
click_element(browser, "button[type='submit']")
wait_until_appeared(browser, "div[class='message success']")
url = reverse("shuup:index")
browser.visit("%s%s" % (live_server, url))
def has_alert(browser):
try:
return browser.get_alert().text == "works"
except:
return False
wait_until_condition(browser, has_alert)
browser.get_alert().accept()
theme = get_current_theme(shop)
snippet = Snippet.objects.filter(shop=shop).first()
snippet.themes = [theme.identifier]
snippet.save()
cache.clear()
browser.visit("%s%s" % (live_server, url))
wait_until_condition(browser, has_alert)
browser.get_alert().accept()
snippet.themes = ["doesnt-exist"]
snippet.save()
cache.clear()
browser.visit("%s%s" % (live_server, url))
wait_until_condition(browser, lambda x: x.is_text_present("Welcome to Default!"))
with pytest.raises(Exception):
browser.get_alert()
# delete the snippet
url = reverse("shuup_admin:xtheme_snippet.edit", kwargs=dict(pk=snippet.pk))
browser.visit("%s%s" % (live_server, url))
assert Snippet.objects.filter(shop=shop).exists()
click_element(browser, ".shuup-toolbar button.btn.btn-danger")
browser.get_alert().accept()
wait_until_condition(browser, lambda x: not Snippet.objects.filter(shop=shop).exists())
示例8: test_menu
def test_menu(browser, admin_user, live_server, settings):
shop = get_default_shop()
initialize_admin_browser_test(browser, live_server, settings)
browser.find_by_css(".menu-list li").first.click()
wait_until_condition(browser, lambda x: x.is_text_present("New product"))
# Make sure that the menu is clickable in small devices
browser.driver.set_window_size(480, 960)
browser.find_by_css("#menu-button").first.click()
browser.find_by_css(".menu-list li").first.click()
wait_until_condition(browser, lambda x: x.is_text_present("New product"))
示例9: categories_filter_test
def categories_filter_test(browser, first_cat, second_cat, third_cat):
# Add all products in second category to also in first category
for shop_product in ShopProduct.objects.filter(primary_category=second_cat):
shop_product.categories.add(first_cat)
# Add one product including first_cat also to third_cat
shop_product = ShopProduct.objects.filter(primary_category=first_cat).last()
shop_product.categories.add(third_cat)
# Activate categories filter for current category which is the first one
set_configuration(
category=first_cat,
data={
"override_default_configuration": True,
"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_category": True
}
)
browser.reload()
wait_until_condition(browser, lambda x: x.is_element_present_by_id("categories-%s" % third_cat.id))
browser.execute_script("$('#categories-%s').click();" % third_cat.id)
wait_until_condition(browser, lambda x: len(x.find_by_css(".product-card")) == 1)
browser.execute_script("$('#categories-%s').click();" % second_cat.id)
wait_until_condition(browser, lambda x: len(x.find_by_css(".product-card")) == 1)
browser.execute_script("$('#categories-%s').click();" % third_cat.id)
wait_until_condition(browser, lambda x: len(x.find_by_css(".product-card")) == 12)
示例10: second_category_sort_test
def second_category_sort_test(browser, live_server, shop, category):
url = reverse("shuup:category", kwargs={"pk": category.pk, "slug": category.slug})
browser.visit("%s%s" % (live_server, url))
wait_until_condition(browser, lambda x: x.is_element_present_by_css("button[data-id='id_limit']"), timeout=30)
# Set limit to 24
click_element(browser, "button[data-id='id_limit']")
click_element(browser, "button[data-id='id_limit'] + .dropdown-menu li[data-original-index='1'] a")
wait_until_condition(browser, lambda x: len(x.find_by_css(".product-card")) == 13, timeout=30)
# Check that visibility change affects the product count
shop_products = ShopProduct.objects.filter(primary_category_id=category.id)[:3]
for sp in shop_products:
sp.visibility = ShopProductVisibility.NOT_VISIBLE
sp.save()
cache.clear()
browser.reload()
wait_until_condition(browser, lambda x: len(x.find_by_css(".product-card")) == 10)
for sp in shop_products:
sp.visibility = ShopProductVisibility.ALWAYS_VISIBLE
sp.save()
cache.clear()
browser.reload()
wait_until_condition(browser, lambda x: len(x.find_by_css(".product-card")) == 13, timeout=30)
示例11: second_category_sort_with_price_filter
def second_category_sort_with_price_filter(browser, category):
set_configuration(
category=category,
data={
"override_default_configuration": True,
"filter_products_by_price": True,
"filter_products_by_price_range_min": 5,
"filter_products_by_price_range_max": 12,
"filter_products_by_price_range_size": 3
}
)
browser.reload()
wait_until_condition(browser, lambda x: len(x.find_by_css("#id_price_range option")) == 5)
# 5 products and let's filter all products with price less than 5
click_element(browser, "button[data-id='id_price_range']")
click_element(browser, "button[data-id='id_price_range'] + .dropdown-menu li[data-original-index='1'] a")
# 4 products and let's filter products with price +12
wait_until_condition(browser, lambda x: len(x.find_by_css(".product-card")) == 4)
click_element(browser, "button[data-id='id_price_range']")
click_element(browser, "button[data-id='id_price_range'] + .dropdown-menu li[data-original-index='4'] a")
# Now 2 products left and now filter with price 8-11
wait_until_condition(browser, lambda x: len(x.find_by_css(".product-card")) == 2)
click_element(browser, "button[data-id='id_price_range']")
click_element(browser, "button[data-id='id_price_range'] + .dropdown-menu li[data-original-index='3'] a")
wait_until_condition(browser, lambda x: len(x.find_by_css(".product-card")) == 3)
示例12: basic_sorting_test
def basic_sorting_test(browser):
# Sort from Z to A
click_element(browser, "button[data-id='id_sort']")
# WARNING: data-original-index was removed after bootstrap-select 1.6.3
click_element(browser, "li[data-original-index='1'] a")
expected_first_prod_id = "product-%s" % Product.objects.filter(sku="sku-3").first().id
wait_until_condition(
browser, lambda x: x.find_by_css(".product-card").first["id"] == expected_first_prod_id)
# Sort by price (highest first)
click_element(browser, "button[data-id='id_sort']")
click_element(browser, "li[data-original-index='3'] a")
expected_first_prod_id = "product-%s" % Product.objects.filter(sku="sku-8").first().id
wait_until_condition(
browser, lambda x: x.find_by_css(".product-card").first["id"] == expected_first_prod_id)
# Sort by price (lowest first)
click_element(browser, "button[data-id='id_sort']")
click_element(browser, "li[data-original-index='2'] a")
expected_first_prod_id = "product-%s" % Product.objects.filter(sku="sku-3").first().id
wait_until_condition(
browser, lambda x: x.find_by_css(".product-card").first["id"] == expected_first_prod_id)
# Sort from A to Z
click_element(browser, "button[data-id='id_sort']")
click_element(browser, "li[data-original-index='0'] a")
expected_first_prod_id = "product-%s" % Product.objects.filter(sku="sku-2").first().id
wait_until_condition(
browser, lambda x: x.find_by_css(".product-card").first["id"] == expected_first_prod_id)
示例13: second_category_sort_test
def second_category_sort_test(browser, live_server, shop, category):
url = reverse("shuup:category", kwargs={"pk": category.pk, "slug": category.slug})
browser.visit("%s%s" % (live_server, url))
assert not browser.is_text_present("Sort") # Sort shouldn't be available since default configurations
wait_until_condition(browser, lambda x: len(x.find_by_css(".product-card")) == 12)
click_element(browser, "#next_page a")
wait_until_condition(browser, lambda x: len(x.find_by_css(".product-card")) == 1, timeout=30)
click_element(browser, "#previous_page a")
wait_until_condition(browser, lambda x: len(x.find_by_css(".product-card")) == 12, timeout=30)
# Activate limit page size changer
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
}
)
browser.reload()
# Set limit to 24
click_element(browser, "button[data-id='id_limit']")
click_element(browser, "button[data-id='id_limit'] + .dropdown-menu li[data-original-index='1'] a")
wait_until_condition(browser, lambda x: len(x.find_by_css(".product-card")) == 13)
示例14: second_test_query
def second_test_query(browser, live_server, url):
browser.visit("%s%s?q=Test" % (live_server, url))
wait_until_condition(browser, lambda x: len(x.find_by_css(".product-card")) == 7)
expected_first_prod_id = "product-%s" % Product.objects.filter(sku="sku-4").first().id
wait_until_condition(browser, lambda x: x.find_by_css(".product-card").first["id"] == expected_first_prod_id)
expected_second_prod_id = "product-%s" % Product.objects.filter(sku="sku-10").first().id
wait_until_condition(browser, lambda x: x.find_by_css(".product-card")[1]["id"] == expected_second_prod_id)
expected_third_prod_id = "product-%s" % Product.objects.filter(sku="sku-8").first().id
wait_until_condition(browser, lambda x: x.find_by_css(".product-card")[2]["id"] == expected_third_prod_id)
expected_last_prod_id = "product-%s" % Product.objects.filter(sku="sku-2").first().id
wait_until_condition(browser, lambda x: x.find_by_css(".product-card").last["id"] == expected_last_prod_id)
示例15: test_quick_add
def test_quick_add(browser, admin_user, live_server, settings):
shop = get_default_shop()
get_default_product_type()
get_default_sales_unit()
get_default_tax_class()
initialize_admin_browser_test(browser, live_server, settings)
url = reverse("shuup_admin:shop_product.new")
browser.visit("%s%s" % (live_server, url))
sku = "testsku"
name = "Some product name"
price_value = 10
short_description = "short but gold"
browser.fill("base-sku", sku)
browser.fill("base-name__en", name)
browser.fill("base-short_description__en", short_description)
browser.fill("shop%s-default_price_value" % shop.pk, price_value)
wait_until_appeared(browser, "#id_shop%d-primary_category ~ .quick-add-btn a.btn" % shop.id)
click_element(browser, "#id_shop%d-primary_category ~ .quick-add-btn a.btn" % shop.id)
wait_until_appeared(browser, "#create-object-iframe")
with browser.get_iframe('create-object-iframe') as iframe:
assert Category.objects.count() == 0
wait_until_appeared(iframe, "input[name='base-name__en']")
iframe.fill("base-name__en", "Test Category")
time.sleep(3) # Let's just wait here to the iFrame to open fully (for Chrome and headless)
wait_until_appeared(iframe, "button[form='category_form']")
click_element(browser, "button[form='category_form']")
wait_until_condition(browser, condition=lambda x: Category.objects.count() == 1, timeout=20)
assert Category.objects.first().name == "Test Category"
# click to edit the button
click_element(browser, "#id_shop%d-primary_category ~ .edit-object-btn a.btn" % shop.id)
with browser.get_iframe('create-object-iframe') as iframe:
wait_until_appeared(iframe, "input[name='base-name__en']")
new_cat_name = "Changed Name"
iframe.fill("base-name__en", new_cat_name)
time.sleep(3) # Let's just wait here to the iFrame to open fully (for Chrome and headless)
wait_until_appeared(iframe, "button[form='category_form']")
click_element(iframe, "button[form='category_form']")
wait_until_condition(browser, condition=lambda x: Category.objects.first().name == new_cat_name, timeout=20)
click_element(browser, "button[form='product_form']")
wait_until_appeared(browser, "div[class='message success']")