• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python asserts.assert_success函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了assert_success函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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"))
开发者ID:atotic,项目名称:web-platform-tests,代码行数:7,代码来源:get_title.py


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


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


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


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


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


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


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


示例9: test_maximize

def test_maximize(session):
    before_size = session.window.size

    response = maximize(session)
    assert_success(response)

    assert before_size != session.window.size
开发者ID:Coder206,项目名称:servo,代码行数:7,代码来源:maximize.py


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


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


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


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


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


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


示例16: test_source_matches_outer_html

def test_source_matches_outer_html(session):
    session.url = inline("<html><head><title>Cheese</title><body>Peas")

    expected = session.execute_script("return document.documentElement.outerHTML")

    response = get_page_source(session)
    assert_success(response, expected)
开发者ID:ConnorGBrewster,项目名称:servo,代码行数:7,代码来源:source.py


示例17: test_not_blurred

def test_not_blurred(session, tag):
    session.url = inline("<%s>" % tag)
    element = session.find.css(tag, all=False)

    response = element_send_keys(session, element, "")
    assert_success(response)
    assert_element_has_focus(element)
开发者ID:ConnorGBrewster,项目名称:servo,代码行数:7,代码来源:events.py


示例18: test_negative_x_y

def test_negative_x_y(session):
    original = session.window.rect

    # step 13
    response = set_window_rect(session, {"x": - 8, "y": - 8})

    # step 14
    os = session.capabilities["platformName"]
    # certain WMs prohibit windows from being moved off-screen
    if os == "linux":
        rect = assert_success(response)
        assert rect["x"] <= 0
        assert rect["y"] <= 0
        assert rect["width"] == original["width"]
        assert rect["height"] == original["height"]

    # On macOS, windows can only be moved off the screen on the
    # horizontal axis.  The system menu bar also blocks windows from
    # being moved to (0,0).
    elif os == "darwin":
        assert_success(response, {"x": -8,
                                  "y": 23,
                                  "width": original["width"],
                                  "height": original["height"]})

    # It turns out that Windows is the only platform on which the
    # window can be reliably positioned off-screen.
    elif os == "windows_nt":
        assert_success(response, {"x": -8,
                                  "y": -8,
                                  "width": original["width"],
                                  "height": original["height"]})
开发者ID:Spec-Ops,项目名称:web-platform-tests,代码行数:32,代码来源:set_window_rect.py


示例19: test_scroll_into_element_view

def test_scroll_into_element_view(session):
    # 14.2 Step 4
    session.url = inline("<input type=text value=Federer><div style= \"height: 200vh; width: 5000vh\">")

    # Scroll to the bottom right of the page
    session.execute_script("window.scrollTo(document.body.scrollWidth, document.body.scrollHeight);")
    element = session.find.css("input", all=False)
    # Clear and scroll back to the top of the page
    response = clear(session, element)
    assert_success(response)

    # Check if element cleared is scrolled into view
    rect = session.execute_script("return document.getElementsByTagName(\"input\")[0].getBoundingClientRect()")

    pageDict = {}

    pageDict["innerHeight"] = session.execute_script("return window.innerHeight")
    pageDict["innerWidth"] = session.execute_script("return window.innerWidth")
    pageDict["pageXOffset"] = session.execute_script("return window.pageXOffset")
    pageDict["pageYOffset"] = session.execute_script("return window.pageYOffset")

    assert rect["top"] < (pageDict["innerHeight"] + pageDict["pageYOffset"]) and \
           rect["left"] < (pageDict["innerWidth"] + pageDict["pageXOffset"]) and \
           (rect["top"] + element.rect["height"]) > pageDict["pageYOffset"] and \
           (rect["left"] + element.rect["width"]) > pageDict["pageXOffset"]
开发者ID:emilio,项目名称:servo,代码行数:25,代码来源:element_clear.py


示例20: test_find_element_partial_link_text

def test_find_element_partial_link_text(session, document, value):
    # Step 8 - 9
    session.url = inline("<div>{0}</div>".format(document))
    element = session.find.css("div", all=False)

    response = find_element(session, element.id, "partial link text", value)
    assert_success(response)
开发者ID:ConnorGBrewster,项目名称:servo,代码行数:7,代码来源:find.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python fixtures.create_dialog函数代码示例发布时间:2022-05-27
下一篇:
Python asserts.assert_same_element函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap