def test_get_window_rect_no_browsing_context(session, create_window):
    # Step 1
    session.window_handle = create_window()
    session.close()
    result = session.transport.send("GET", "session/%s/window/rect" % session.session_id)

    assert_error(result, "no such window")
Beispiel #2
0
def test_get_current_url_alert_prompt(session):
    # 7.2 step 2
    session.url = alert_doc

    result = session.transport.send("GET", "session/%s/url" % session.session_id)

    assert_error(result, "unexpected alert open")
Beispiel #3
0
def test_get_window_rect_no_browsing_context(session, create_window):
    # Step 1
    session.window_handle = create_window()
    session.close()
    result = session.transport.send(
        "GET", "session/%s/window/rect" % session.session_id)

    assert_error(result, "no such window")
Beispiel #4
0
def test_get_current_url_no_browsing_context(session, create_window):
    # 7.2 step 1
    session.window_handle = create_window()
    session.close()

    result = session.transport.send("GET", "session/%s/url" % session.session_id)

    assert_error(result, "no such window")
Beispiel #5
0
def test_get_current_url_alert_prompt(session):
    # 7.2 step 2
    session.url = alert_doc

    result = session.transport.send("GET",
                                    "session/%s/url" % session.session_id)

    assert_error(result, "unexpected alert open")
Beispiel #6
0
def test_maximize_rect_alert_prompt(session):
    # Step 2
    session.url = alert_doc

    result = session.transport.send(
        "POST", "session/%s/window/maximize" % session.session_id)

    assert_error(result, "unexpected alert open")
Beispiel #7
0
def test_maximize_no_browsing_context(session, create_window):
    # Step 1
    session.window_handle = create_window()
    session.close()
    result = session.transport.send(
        "POST", "session/%s/window/maximize" % session.session_id)

    assert_error(result, "no such window")
Beispiel #8
0
def test_closed_context(session, create_window):
    new_window = create_window()
    session.window_handle = new_window
    session.close()

    result = session.transport.send(
        "GET", "session/%s/element/active" % session.session_id)

    assert_error(result, "no such window")
Beispiel #9
0
def test_get_current_url_no_browsing_context(session, create_window):
    # 7.2 step 1
    session.window_handle = create_window()
    session.close()

    result = session.transport.send("GET",
                                    "session/%s/url" % session.session_id)

    assert_error(result, "no such window")
def test_title_from_closed_context(session, create_window):
    new_window = create_window()
    session.window_handle = new_window
    session.close()

    result = session.transport.send("GET",
                                    "session/%s/title" % session.session_id)

    assert_error(result, "no such window")
Beispiel #11
0
def test_out_of_bounds(session, rect):
    """
    8. If width or height is neither null nor a Number from 0 to 2^64 -
    1, return error with error code invalid argument.

    9. If x or y is neither null nor a Number from -(263) to 263 - 1,
    return error with error code invalid argument.
    """
    response = set_window_rect(session, rect)
    assert_error(response, "invalid argument")
Beispiel #12
0
def test_current_top_level_browsing_context_no_longer_open(
        session, create_window):
    """
    1. If the current top-level browsing context is no longer open,
    return error with error code no such window.
    """

    session.window_handle = create_window()
    session.close()
    response = set_window_rect(session, {})
    assert_error(response, "no such window")
Beispiel #13
0
def test_title_handle_prompt_missing_value(session, create_dialog):
    session.url = inline("<title>WD doc title</title>")
    create_dialog("alert", text="dismiss #1", result_var="dismiss1")

    result = session.transport.send("GET",
                                    "session/%s/title" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #1")
    assert read_global(session, "accept1") == None

    create_dialog("confirm", text="dismiss #2", result_var="dismiss2")

    result = session.transport.send("GET",
                                    "session/%s/title" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #2")
    assert read_global(session, "dismiss2") == False

    create_dialog("prompt", text="dismiss #3", result_var="dismiss3")

    result = session.transport.send("GET",
                                    "session/%s/title" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #3")
    assert read_global(session, "dismiss3") == None
def test_title_handle_prompt_missing_value(session, create_dialog):
    session.url = inline("<title>WD doc title</title>")
    create_dialog("alert", text="dismiss #1", result_var="dismiss1")

    result = session.transport.send("GET",
                                    "session/%s/title" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #1")
    assert read_global(session, "accept1") == None

    create_dialog("confirm", text="dismiss #2", result_var="dismiss2")

    result = session.transport.send("GET",
                                    "session/%s/title" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #2")
    assert read_global(session, "dismiss2") == False

    create_dialog("prompt", text="dismiss #3", result_var="dismiss3")

    result = session.transport.send("GET",
                                    "session/%s/title" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #3")
    assert read_global(session, "dismiss3") == None
Beispiel #15
0
def test_handle_prompt_missing_value(session, create_dialog):
    original = session.window.rect

    # step 2
    session.url = inline("<title>WD doc title</title>")
    create_dialog("alert", text="dismiss #1", result_var="dismiss1")

    result = set_window_rect(session, {
        "x": int(original["x"]),
        "y": int(original["y"])
    })
    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #1")

    create_dialog("confirm", text="dismiss #2", result_var="dismiss2")

    result = set_window_rect(session, {
        "x": int(original["x"]),
        "y": int(original["y"])
    })
    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #2")

    create_dialog("prompt", text="dismiss #3", result_var="dismiss3")

    result = set_window_rect(session, {
        "x": int(original["x"]),
        "y": int(original["y"])
    })
    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #3")
def test_get_window_rect_handle_prompt_missing_value(session, create_dialog):
    # Step 2
    session.url = inline("<title>WD doc title</title>")
    create_dialog("alert", text="dismiss #1", result_var="dismiss1")

    result = session.transport.send("GET",
                                    "session/%s/window/rect" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #1")

    create_dialog("confirm", text="dismiss #2", result_var="dismiss2")

    result = session.transport.send("GET",
                                    "session/%s/window/rect" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #2")

    create_dialog("prompt", text="dismiss #3", result_var="dismiss3")

    result = session.transport.send("GET",
                                    "session/%s/window/rect" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #3")
Beispiel #17
0
def test_handle_prompt_missing_value(session, create_dialog):
    session.url = inline("<body><p>Hello, World!</p></body>")

    create_dialog("alert", text="dismiss #1", result_var="dismiss1")

    result = session.transport.send("GET",
                                    "session/%s/element/active" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #1")
    assert session.execute_script("return accept1;") == None

    create_dialog("confirm", text="dismiss #2", result_var="dismiss2")

    result = session.transport.send("GET",
                                    "session/%s/element/active" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #2")
    assert session.execute_script("return dismiss2;") == False

    create_dialog("prompt", text="dismiss #3", result_var="dismiss3")

    result = session.transport.send("GET",
                                    "session/%s/element/active" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #3")
    assert session.execute_script("return dismiss3;") == None
Beispiel #18
0
def test_handle_prompt_missing_value(session, create_dialog):
    session.url = inline("<body><p>Hello, World!</p></body>")

    create_dialog("alert", text="dismiss #1", result_var="dismiss1")

    result = session.transport.send(
        "GET", "session/%s/element/active" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #1")
    assert session.execute_script("return accept1;") == None

    create_dialog("confirm", text="dismiss #2", result_var="dismiss2")

    result = session.transport.send(
        "GET", "session/%s/element/active" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #2")
    assert session.execute_script("return dismiss2;") == False

    create_dialog("prompt", text="dismiss #3", result_var="dismiss3")

    result = session.transport.send(
        "GET", "session/%s/element/active" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #3")
    assert session.execute_script("return dismiss3;") == None
Beispiel #19
0
def test_get_window_rect_handle_prompt_missing_value(session, create_dialog):
    # Step 2
    session.url = inline("<title>WD doc title</title>")
    create_dialog("alert", text="dismiss #1", result_var="dismiss1")

    result = session.transport.send(
        "GET", "session/%s/window/rect" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #1")

    create_dialog("confirm", text="dismiss #2", result_var="dismiss2")

    result = session.transport.send(
        "GET", "session/%s/window/rect" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #2")

    create_dialog("prompt", text="dismiss #3", result_var="dismiss3")

    result = session.transport.send(
        "GET", "session/%s/window/rect" % session.session_id)

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #3")
Beispiel #20
0
def test_handle_prompt_missing_value(session, create_dialog):
    """
    2. Handle any user prompts and return its value if it is an error.

    [...]

    In order to handle any user prompts a remote end must take the
    following steps:

      [...]

      2. Perform the following substeps based on the current session's
      user prompt handler:

        [...]

        - missing value default state
           1. Dismiss the current user prompt.
           2. Return error with error code unexpected alert open.

    """

    original = session.window.rect

    # step 2
    create_dialog("alert", text="dismiss #1", result_var="dismiss1")

    result = set_window_rect(session, {
        "x": int(original["x"]),
        "y": int(original["y"])
    })
    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #1")

    create_dialog("confirm", text="dismiss #2", result_var="dismiss2")

    result = set_window_rect(session, {
        "x": int(original["x"]),
        "y": int(original["y"])
    })
    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #2")

    create_dialog("prompt", text="dismiss #3", result_var="dismiss3")

    result = set_window_rect(session, {
        "x": int(original["x"]),
        "y": int(original["y"])
    })
    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #3")
def test_set_window_rect_handle_prompt_missing_value(session, create_dialog):
    # Step 2
    get_response = session.transport.send(
        "GET", "session/%s/window/rect" % session.session_id)
    original = get_response.body["value"]

    session.url = inline("<title>WD doc title</title>")
    create_dialog("alert", text="dismiss #1", result_var="dismiss1")

    result = session.transport.send(
        "POST", "session/%s/window/rect" % session.session_id, {
            "x": int(original["y"]),
            "y": int(original["y"])
        })

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #1")

    create_dialog("confirm", text="dismiss #2", result_var="dismiss2")

    result = session.transport.send(
        "POST", "session/%s/window/rect" % session.session_id, {
            "x": int(original["y"]),
            "y": int(original["y"])
        })

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #2")

    create_dialog("prompt", text="dismiss #3", result_var="dismiss3")

    result = session.transport.send(
        "POST", "session/%s/window/rect" % session.session_id, {
            "x": int(original["y"]),
            "y": int(original["y"])
        })

    assert_error(result, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #3")
Beispiel #22
0
def test_set_malformed_url(session):
    result = session.transport.send("POST",
                                    "session/%s/url" % session.session_id,
                                    {"url": "foo"})

    assert_error(result, "invalid argument")
Beispiel #23
0
def test_invalid_params(session, data):
    # step 8-9
    response = set_window_rect(session, data)
    assert_error(response, "invalid argument")
Beispiel #24
0
def test_set_malformed_url(session):
    result = session.transport.send("POST",
                                    "session/%s/url" % session.session_id,
                                    {"url": "foo"})

    assert_error(result, "invalid argument")
def test_set_window_rect_invalid_params(session, data):
    # step 8-9
    result = session.transport.send(
        "POST", "session/%s/window/rect" % session.session_id, data)

    assert_error(result, "invalid argument")