当前位置: 首页>>代码示例>>Python>>正文


Python asserts.assert_same_element函数代码示例

本文整理汇总了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)
开发者ID:EdgarChen,项目名称:web-platform-tests,代码行数:7,代码来源:find_element.py

示例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)
开发者ID:ConnorGBrewster,项目名称:servo,代码行数:8,代码来源:find.py

示例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)
开发者ID:EdgarChen,项目名称:servo,代码行数:11,代码来源:find_elements.py

示例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"])
开发者ID:Coder206,项目名称:servo,代码行数:11,代码来源:cyclic.py

示例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)
开发者ID:Coder206,项目名称:servo,代码行数:12,代码来源:cyclic.py

示例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)
开发者ID:Jayflux,项目名称:servo,代码行数:12,代码来源:find_elements.py

示例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)
开发者ID:Coder206,项目名称:servo,代码行数:12,代码来源:user_prompts.py

示例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)
开发者ID:Jayflux,项目名称:servo,代码行数:13,代码来源:collections.py

示例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)
开发者ID:Jayflux,项目名称:servo,代码行数:13,代码来源:collections.py

示例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)
开发者ID:Spec-Ops,项目名称:web-platform-tests,代码行数:13,代码来源:get_active_element.py

示例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)
开发者ID:Jayflux,项目名称:servo,代码行数:15,代码来源:collections.py

示例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)
开发者ID:Jayflux,项目名称:servo,代码行数:15,代码来源:collections.py

示例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)
开发者ID:Honry,项目名称:web-platform-tests,代码行数:17,代码来源:properties.py

示例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"
开发者ID:EdgarChen,项目名称:servo,代码行数:17,代码来源:interactability.py

示例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])
开发者ID:Jayflux,项目名称:servo,代码行数:21,代码来源:collections.py


注:本文中的tests.support.asserts.assert_same_element函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。