本文整理汇总了Python中tests.support.asserts.assert_success函数的典型用法代码示例。如果您正苦于以下问题:Python assert_success函数的具体用法?Python assert_success怎么用?Python assert_success使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_success函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_title_without_element
def test_title_without_element(session):
session.url = inline("<h2>Hello</h2>")
result = session.transport.send("GET",
"session/%s/title" % session.session_id)
assert_success(result, read_global(session, "document.title"))
示例2: test_add_cookie_for_ip
def test_add_cookie_for_ip(session, url, server_config, configuration):
new_cookie = {
"name": "hello",
"value": "world",
"domain": "127.0.0.1",
"path": "/",
"httpOnly": False,
"secure": False
}
session.url = "http://127.0.0.1:%s/common/blank.html" % (server_config["ports"]["http"][0])
clear_all_cookies(session)
result = add_cookie(session, new_cookie)
assert_success(result)
cookie = session.cookies("hello")
assert "name" in cookie
assert isinstance(cookie["name"], basestring)
assert "value" in cookie
assert isinstance(cookie["value"], basestring)
assert "domain" in cookie
assert isinstance(cookie["domain"], basestring)
assert cookie["name"] == "hello"
assert cookie["value"] == "world"
assert cookie["domain"] == "127.0.0.1"
示例3: test_resettable_element_does_not_satisfy_validation_constraints
def test_resettable_element_does_not_satisfy_validation_constraints(session, type, invalid_value):
"""
Some UAs allow invalid input to certain types of constrained
form controls. For example, Gecko allows non-valid characters
to be typed into <input type=number> but Chrome does not.
Since we want to test that Element Clear works for clearing the
invalid characters in these UAs, it is fine to skip this test
where UAs do not allow the element to not satisfy its constraints.
"""
session.url = inline("<input type=%s>" % type)
element = session.find.css("input", all=False)
def is_valid(element):
return session.execute_script("""
var input = arguments[0];
return input.validity.valid;
""", args=(element,))
# value property does not get updated if the input is invalid
element.send_keys(invalid_value)
# UA does not allow invalid input for this form control type
if is_valid(element):
return
response = element_clear(session, element)
assert_success(response)
assert is_valid(element)
示例4: test_set_to_state_cross_realm
def test_set_to_state_cross_realm(session, create_window, state, realmSetting):
original_window = session.window_handle
session.window_handle = create_window()
parameters = { "descriptor": { "name": "geolocation" }, "state": state }
parameters.update(realmSetting)
response = session.transport.send(
"POST", "/session/{session_id}/permissions".format(**vars(session)),
parameters
)
try:
assert_success(response)
except AssertionError:
# > 4. If parameters.state is an inappropriate permission state for any
# > implementation-defined reason, return a WebDriver error with
# > WebDriver error code invalid argument.
assert_error(response, "invalid argument")
return
assert response.body.get("value") == None
session.window_handle = original_window
response = query(session, "geolocation")
assert_success(response)
result = response.body.get("value")
assert isinstance(result, dict)
assert result.get("status") == "success"
assert result.get("value") == state
示例5: test_add_session_cookie_with_leading_dot_character_in_domain
def test_add_session_cookie_with_leading_dot_character_in_domain(session, url, server_config):
new_cookie = {
"name": "hello",
"value": "world",
"domain": ".%s" % server_config["browser_host"]
}
session.url = url("/common/blank.html")
clear_all_cookies(session)
result = add_cookie(session, new_cookie)
assert_success(result)
cookie = session.cookies("hello")
assert "name" in cookie
assert isinstance(cookie["name"], basestring)
assert "value" in cookie
assert isinstance(cookie["value"], basestring)
assert "domain" in cookie
assert isinstance(cookie["domain"], basestring)
assert cookie["name"] == "hello"
assert cookie["value"] == "world"
assert cookie["domain"] == server_config["browser_host"] or \
cookie["domain"] == ".%s" % server_config["browser_host"]
示例6: test_get_current_url_nested_browsing_context
def test_get_current_url_nested_browsing_context(session, create_frame):
session.url = "about:blank#wd_from_within_frame"
session.switch_frame(create_frame())
result = session.transport.send("GET", "session/%s/url" % session.session_id)
assert_success(result, "about:blank#wd_from_within_frame")
示例7: test_transparent_element
def test_transparent_element(session):
session.url = inline("""<input style="opacity: 0">""")
element = session.find.css("input", all=False)
response = element_send_keys(session, element, "foo")
assert_success(response)
assert element.property("value") == "foo"
示例8: test_fully_exit_fullscreen
def test_fully_exit_fullscreen(session):
session.window.fullscreen()
assert is_fullscreen(session)
response = maximize(session)
assert_success(response)
assert not is_fullscreen(session)
示例9: test_maximize
def test_maximize(session):
before_size = session.window.size
response = maximize(session)
assert_success(response)
assert before_size != session.window.size
示例10: test_checkbox_not_selected
def test_checkbox_not_selected(session):
# 13.1 step 5
session.url = check_doc
element = session.find.css("#notChecked", all=False)
result = is_element_selected(session, element.id)
assert_success(result, False)
示例11: test_element_not_selected
def test_element_not_selected(session):
# 13.1 step 5
session.url = option_doc
element = session.find.css("#notSelected", all=False)
result = is_element_selected(session, element.id)
assert_success(result, False)
示例12: test_handle_prompt_accept
def test_handle_prompt_accept(session, create_dialog, dialog_type):
create_dialog(dialog_type, text="dialog")
response = get_window_rect(session)
assert_success(response)
assert_dialog_handled(session, expected_text="dialog")
示例13: test_handle_prompt_ignore
def test_handle_prompt_ignore(session, dialog_type):
response = execute_async_script(session, "window.{}('Hello');".format(dialog_type))
assert_success(response, None)
with pytest.raises(error.UnexpectedAlertOpenException):
session.title
session.alert.dismiss()
示例14: test_handle_prompt_dismiss
def test_handle_prompt_dismiss(session, dialog_type):
response = execute_async_script(session, "window.{}('Hello');".format(dialog_type))
assert_success(response, None)
session.title
with pytest.raises(error.NoSuchAlertException):
session.alert.dismiss()
示例15: test_history_pushstate
def test_history_pushstate(session, url):
pushstate_page = inline("""
<script>
function pushState() {
history.pushState({foo: "bar"}, "", "#pushstate");
}
</script>
<a onclick="javascript:pushState();">click</a>
""")
session.url = pushstate_page
session.find.css("a", all=False).click()
assert session.url == "{}#pushstate".format(pushstate_page)
assert session.execute_script("return history.state;") == {"foo": "bar"}
session.execute_script("""
let elem = window.document.createElement('div');
window.document.body.appendChild(elem);
""")
element = session.find.css("div", all=False)
response = refresh(session)
assert_success(response)
assert session.url == "{}#pushstate".format(pushstate_page)
assert session.execute_script("return history.state;") == {"foo": "bar"}
with pytest.raises(StaleElementReferenceException):
element.property("id")