本文整理汇总了Python中tests.support.asserts.assert_same_element函数的典型用法代码示例。如果您正苦于以下问题:Python assert_same_element函数的具体用法?Python assert_same_element怎么用?Python assert_same_element使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_same_element函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_xhtml_namespace
def test_xhtml_namespace(session, using, value):
session.url = inline("""<a href="#" id="linkText">full link text</a>""", doctype="xhtml")
expected = session.execute_script("return document.links[0]")
response = find_element(session, using, value)
value = assert_success(response)
assert_same_element(session, value, expected)
示例2: test_parent_htmldocument
def test_parent_htmldocument(session):
session.url = inline("")
from_element = session.execute_script("""return document.querySelector("body")""")
expected = session.execute_script("return document.documentElement")
response = find_element(session, from_element.id, "xpath", "..")
value = assert_success(response)
assert_same_element(session, value, expected)
示例3: test_xhtml_namespace
def test_xhtml_namespace(session, using, value):
session.url = inline("""<p><a href="#" id="linkText">full link text</a></p>""", doctype="xhtml")
expected = session.execute_script("return document.links[0]")
response = find_elements(session, using, value)
value = assert_success(response)
assert isinstance(value, list)
assert len(value) == 1
found_element = value[0]
assert_same_element(session, found_element, expected)
示例4: test_element_in_object
def test_element_in_object(session):
session.url = inline("<div></div>")
div = session.find.css("div", all=False)
response = execute_script(session, """
let div = document.querySelector("div");
div.reference = div;
return {foo: div};
""")
value = assert_success(response)
assert_same_element(session, div, value["foo"])
示例5: test_element_in_collection
def test_element_in_collection(session):
session.url = inline("<div></div>")
divs = session.find.css("div")
response = execute_script(session, """
let div = document.querySelector("div");
div.reference = div;
return [div];
""")
value = assert_success(response)
for expected, actual in zip(divs, value):
assert_same_element(session, expected, actual)
示例6: test_find_elements_partial_link_text
def test_find_elements_partial_link_text(session, document, value):
# Step 8 - 9
session.url = inline("<a href=#>not wanted</a><br/>{0}".format(document))
expected = session.execute_script("return document.links[1];")
response = find_elements(session, "partial link text", value)
value = assert_success(response)
assert isinstance(value, list)
assert len(value) == 1
found_element = value[0]
assert_same_element(session, found_element, expected)
示例7: check_user_prompt_closed_without_exception
def check_user_prompt_closed_without_exception(dialog_type, retval):
session.url = inline("<p>bar</p>")
element = session.find.css("p", all=False)
create_dialog(dialog_type, text=dialog_type)
response = find_element(session, "css selector", "p")
value = assert_success(response)
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
assert_same_element(session, value, element)
示例8: test_html_collection
def test_html_collection(session):
session.url = inline("""
<p>foo
<p>bar
""")
ps = session.find.css("p")
response = execute_script(session, "return document.getElementsByTagName('p')")
value = assert_success(response)
assert isinstance(value, list)
assert len(value) == 2
for expected, actual in zip(ps, value):
assert_same_element(session, expected, actual)
示例9: test_node_list
def test_node_list(session):
session.url = inline("""
<p>foo
<p>bar
""")
ps = session.find.css("p")
response = execute_script(session, "return document.querySelectorAll('p')")
value = assert_success(response)
assert isinstance(value, list)
assert len(value) == 2
for expected, actual in zip(ps, value):
assert_same_element(session, expected, actual)
示例10: assert_result_is_active_element
def assert_result_is_active_element(session, result):
"""Ensure that the provided object is a successful WebDriver response
describing an element reference and that the referenced element matches the
element returned by the `activeElement` attribute of the current browsing
context's active document."""
assert result.status == 200
from_js = session.execute_script("return document.activeElement;")
if result.body["value"] is None:
assert from_js == None
else:
assert_same_element(session, result.body["value"], from_js)
示例11: test_html_form_controls_collection
def test_html_form_controls_collection(session):
session.url = inline("""
<form>
<input>
<input>
</form>
""")
inputs = session.find.css("input")
response = execute_script(session, "return document.forms[0].elements")
value = assert_success(response)
assert isinstance(value, list)
assert len(value) == 2
for expected, actual in zip(inputs, value):
assert_same_element(session, expected, actual)
示例12: test_html_options_collection
def test_html_options_collection(session):
session.url = inline("""
<select>
<option>
<option>
</select>
""")
options = session.find.css("option")
response = execute_script(session, "return document.querySelector('select').options")
value = assert_success(response)
assert isinstance(value, list)
assert len(value) == 2
for expected, actual in zip(options, value):
assert_same_element(session, expected, actual)
示例13: test_idl_attribute_element
def test_idl_attribute_element(session):
session.url = inline("""
<p>foo
<p>bar
<script>
const [foo, bar] = document.querySelectorAll("p");
foo.bar = bar;
</script>
""")
_foo, bar = session.find.css("p")
response = execute_script(session, """
const foo = document.querySelector("p");
return foo.bar;
""")
value = assert_success(response)
assert_same_element(session, bar, value)
示例14: test_body_is_interactable
def test_body_is_interactable(session):
session.url = inline("""
<body onkeypress="document.getElementById('result').value += event.key">
<input type="text" id="result"/>
</body>
""")
element = session.find.css("body", all=False)
result = session.find.css("input", all=False)
# By default body is the active element
assert_same_element(session, element, session.active_element)
response = send_keys_to_element(session, element, "foo")
assert_success(response)
assert_same_element(session, element, session.active_element)
assert result.property("value") == "foo"
示例15: test_html_all_collection
def test_html_all_collection(session):
session.url = inline("""
<p>foo
<p>bar
""")
html = session.find.css("html", all=False)
head = session.find.css("head", all=False)
body = session.find.css("body", all=False)
ps = session.find.css("p")
response = execute_script(session, "return document.all")
value = assert_success(response)
assert isinstance(value, list)
# <html>, <head>, <body>, <p>, <p>
assert len(value) == 5
assert_same_element(session, html, value[0])
assert_same_element(session, head, value[1])
assert_same_element(session, body, value[2])
assert_same_element(session, ps[0], value[3])
assert_same_element(session, ps[1], value[4])