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


Python asserts.assert_error函数代码示例

本文整理汇总了Python中tests.support.asserts.assert_error函数的典型用法代码示例。如果您正苦于以下问题:Python assert_error函数的具体用法?Python assert_error怎么用?Python assert_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了assert_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_element_stale

def test_element_stale(session):
    session.url = inline("<input id=foobar>")
    element = session.find.css("input", all=False)
    session.refresh()

    response = get_element_property(session, element.id, "id")
    assert_error(response, "stale element reference")
开发者ID:Honry,项目名称:web-platform-tests,代码行数:7,代码来源:get.py

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

示例3: test_no_browsing_context

def test_no_browsing_context(session, create_window):
    # 18.1 step 1
    session.window_handle = create_window()
    session.close()

    response = dismiss_alert(session)
    assert_error(response, "no such window")
开发者ID:EdgarChen,项目名称:servo,代码行数:7,代码来源:dismiss_alert.py

示例4: test_array

def test_array(session):
    response = execute_script(session, """
        let arr = [];
        arr.push(arr);
        return arr;
        """)
    assert_error(response, "javascript error")
开发者ID:Coder206,项目名称:servo,代码行数:7,代码来源:cyclic.py

示例5: test_object_in_array

def test_object_in_array(session):
    response = execute_script(session, """
        let obj = {};
        obj.reference = obj;
        return [obj];
        """)
    assert_error(response, "javascript error")
开发者ID:Coder206,项目名称:servo,代码行数:7,代码来源:cyclic.py

示例6: test_element_not_found

def test_element_not_found(session):
    # 14.2 Step 2
    response = session.transport.send("POST", "session/{session_id}/element/{element_id}/clear"
                                      .format(session_id=session.session_id,
                                              element_id="box1"))

    assert_error(response, "no such element")
开发者ID:emilio,项目名称:servo,代码行数:7,代码来源:element_clear.py

示例7: test_disabled_element_not_resettable

def test_disabled_element_not_resettable(session):
    # 14.2 Step 3
    session.url = inline("<input type=text value=Federer disabled>")

    element = session.find.css("input", all=False)
    response = clear(session, element)
    assert_error(response, "invalid element state")
开发者ID:emilio,项目名称:servo,代码行数:7,代码来源:element_clear.py

示例8: test_closed_context

def test_closed_context(session, create_window):
    new_window = create_window()
    session.window_handle = new_window
    session.close()

    response = get_active_element(session)
    assert_error(response, "no such window")
开发者ID:EdgarChen,项目名称:servo,代码行数:7,代码来源:get_active_element.py

示例9: test_no_browsing_context

def test_no_browsing_context(session, create_window):
    # 18.4 step 3
    session.window_handle = create_window()
    session.close()

    response = send_alert_text(session, "Federer")
    assert_error(response, "no such window")
开发者ID:ConnorGBrewster,项目名称:servo,代码行数:7,代码来源:send.py

示例10: test_no_browsing_context

def test_no_browsing_context(session, create_window):
    # 13.1 step 1
    session.window_handle = create_window()
    session.close()

    result = is_element_selected(session, "foo")
    assert_error(result, "no such window")
开发者ID:ConnorGBrewster,项目名称:servo,代码行数:7,代码来源:selected.py

示例11: test_strict_display_none

def test_strict_display_none(session, create_files):
    files = create_files(["foo"])
    session.url = inline("""<input type=file style="display: none">""")
    element = session.find.css("input", all=False)

    response = element_send_keys(session, element, str(files[0]))
    assert_error(response, "element not interactable")
开发者ID:Coder206,项目名称:servo,代码行数:7,代码来源:file_upload.py

示例12: test_handle_prompt_default

def test_handle_prompt_default(session, create_dialog, dialog_type):
    create_dialog(dialog_type, text="dialog")

    response = get_window_rect(session)
    assert_error(response, "unexpected alert open")

    assert_dialog_handled(session, expected_text="dialog")
开发者ID:ConnorGBrewster,项目名称:servo,代码行数:7,代码来源:user_prompts.py

示例13: test_element_stale

def test_element_stale(session):
    session.url = _input
    element = session.find.css("input", all=False)
    session.refresh()

    result = get_element_property(session, element.id, "id")
    assert_error(result, "stale element reference")
开发者ID:Coder206,项目名称:servo,代码行数:7,代码来源:get.py

示例14: test_element_readonly

def test_element_readonly(session):
    # 14.2 Step 7
    session.url = inline("<input type=text readonly value=Federer>")

    element = session.find.css("input", all=False)
    response = clear(session, element)
    assert_error(response, "invalid element state")
开发者ID:emilio,项目名称:servo,代码行数:7,代码来源:element_clear.py

示例15: test_await_promise_reject

def test_await_promise_reject(session):
    response = execute_async_script(session, """
        let resolve = arguments[0];
        await Promise.reject(new Error('my error'));
        resolve('foo');
        """)
    assert_error(response, "javascript error")
开发者ID:Honry,项目名称:web-platform-tests,代码行数:7,代码来源:promise.py


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