示例#1
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")
示例#2
0
def test_prompt_accept(new_session):
    _, session = new_session(
        {"alwaysMatch": {
            "unhandledPromptBehavior": "accept"
        }})
    session.url = inline("<title>WD doc title</title>")
    original = session.window.rect

    # step 2
    create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
    result = set_window_rect(session, {
        "x": int(original["x"]),
        "y": int(original["y"])
    })
    assert result.status == 200
    assert_dialog_handled(session, "dismiss #1")

    create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
    result = set_window_rect(session, {
        "x": int(original["x"]),
        "y": int(original["y"])
    })
    assert result.status == 200
    assert_dialog_handled(session, "dismiss #2")

    create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
    result = set_window_rect(session, {
        "x": int(original["x"]),
        "y": int(original["y"])
    })
    assert_success(result)
    assert_dialog_handled(session, "dismiss #3")
示例#3
0
def test_handle_prompt_dismiss(new_session):
    _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "dismiss"}})
    session.url = inline("<body><p>Hello, World!</p></body>")

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

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

    assert_result_is_active_element(session, result)
    assert_dialog_handled(session, "dismiss #1")
    assert session.execute_script("return dismiss1;") == None

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

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

    assert_result_is_active_element(session, result)
    assert_dialog_handled(session, "dismiss #2")
    assert read_global(session, "dismiss2") == None

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

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

    assert_result_is_active_element(session, result)
    assert_dialog_handled(session, "dismiss #3")
    assert read_global(session, "dismiss3") == None
示例#4
0
def test_handle_prompt_accept(new_session):
    _, session = new_session(
        {"alwaysMatch": {
            "unhandledPromptBehavior": "accept"
        }})
    session.url = inline("<body><p>Hello, World!</p></body>")
    create_dialog(session)("alert", text="accept #1", result_var="accept1")

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

    assert_result_is_active_element(session, result)
    assert_dialog_handled(session, "accept #1")
    assert read_global(session, "accept1") == None

    create_dialog(session)("confirm", text="accept #2", result_var="accept2")

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

    assert_result_is_active_element(session, result)
    assert_dialog_handled(session, "accept #2")
    assert read_global(session, "accept2"), True

    create_dialog(session)("prompt", text="accept #3", result_var="accept3")

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

    assert_result_is_active_element(session, result)
    assert_dialog_handled(session, "accept #3")
    assert read_global(session, "accept3") == ""
示例#5
0
def test_handle_prompt_dismiss(new_session):
    _, session = new_session(
        {"alwaysMatch": {
            "unhandledPromptBehavior": "dismiss"
        }})
    session.url = inline("<body><p>Hello, World!</p></body>")

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

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

    assert_result_is_active_element(session, result)
    assert_dialog_handled(session, "dismiss #1")
    assert session.execute_script("return dismiss1;") == None

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

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

    assert_result_is_active_element(session, result)
    assert_dialog_handled(session, "dismiss #2")
    assert read_global(session, "dismiss2") == None

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

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

    assert_result_is_active_element(session, result)
    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
示例#7
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
def test_title_handle_prompt_accept(new_session):
    _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
    session.url = inline("<title>WD doc title</title>")
    create_dialog(session)("alert", text="accept #1", result_var="accept1")

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

    assert_success(result, expected_title)
    assert_dialog_handled(session, "accept #1")
    assert read_global(session, "accept1") == None

    expected_title = read_global(session, "document.title")
    create_dialog(session)("confirm", text="accept #2", result_var="accept2")

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

    assert_success(result, expected_title)
    assert_dialog_handled(session, "accept #2")
    assert read_global(session, "accept2"), True

    expected_title = read_global(session, "document.title")
    create_dialog(session)("prompt", text="accept #3", result_var="accept3")

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

    assert_success(result, expected_title)
    assert_dialog_handled(session, "accept #3")
    assert read_global(session, "accept3") == ""
示例#9
0
def test_get_window_rect_prompt_accept(new_session):
    # Step 2
    _, session = new_session(
        {"alwaysMatch": {
            "unhandledPromptBehavior": "accept"
        }})
    session.url = inline("<title>WD doc title</title>")

    create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
    result = session.transport.send(
        "GET", "session/%s/window/rect" % session.session_id)
    assert result.status == 200
    assert_dialog_handled(session, "dismiss #1")

    create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
    result = session.transport.send(
        "GET", "session/%s/window/rect" % session.session_id)
    assert result.status == 200
    assert_dialog_handled(session, "dismiss #2")

    create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
    result = session.transport.send(
        "GET", "session/%s/window/rect" % session.session_id)
    assert result.status == 200
    assert_dialog_handled(session, "dismiss #3")
示例#10
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")
示例#11
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
示例#12
0
def test_handle_prompt_accept(new_session):
    _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
    session.url = inline("<body><p>Hello, World!</p></body>")
    create_dialog(session)("alert", text="accept #1", result_var="accept1")

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

    assert_result_is_active_element(session, result)
    assert_dialog_handled(session, "accept #1")
    assert read_global(session, "accept1") == None

    create_dialog(session)("confirm", text="accept #2", result_var="accept2")

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

    assert_result_is_active_element(session, result)
    assert_dialog_handled(session, "accept #2")
    assert read_global(session, "accept2"), True

    create_dialog(session)("prompt", text="accept #3", result_var="accept3")

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

    assert_result_is_active_element(session, result)
    assert_dialog_handled(session, "accept #3")
    assert read_global(session, "accept3") == ""
示例#13
0
def test_title_handle_prompt_accept(new_session):
    _, session = new_session(
        {"alwaysMatch": {
            "unhandledPromptBehavior": "accept"
        }})
    session.url = inline("<title>WD doc title</title>")
    create_dialog(session)("alert", text="accept #1", result_var="accept1")

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

    assert_success(result, expected_title)
    assert_dialog_handled(session, "accept #1")
    assert read_global(session, "accept1") == None

    expected_title = read_global(session, "document.title")
    create_dialog(session)("confirm", text="accept #2", result_var="accept2")

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

    assert_success(result, expected_title)
    assert_dialog_handled(session, "accept #2")
    assert read_global(session, "accept2"), True

    expected_title = read_global(session, "document.title")
    create_dialog(session)("prompt", text="accept #3", result_var="accept3")

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

    assert_success(result, expected_title)
    assert_dialog_handled(session, "accept #3")
    assert read_global(session, "accept3") == ""
示例#14
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_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")
示例#16
0
def test_handle_prompt_accept(new_session):
    """
    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:

        [...]

        - accept state
           Accept the current user prompt.

    """

    _, session = new_session(
        {"alwaysMatch": {
            "unhandledPromptBehavior": "accept"
        }})
    original = session.window.rect

    # step 2
    create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
    result = set_window_rect(session, {
        "x": int(original["x"]),
        "y": int(original["y"])
    })
    assert result.status == 200
    assert_dialog_handled(session, "dismiss #1")

    create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
    result = set_window_rect(session, {
        "x": int(original["x"]),
        "y": int(original["y"])
    })
    assert result.status == 200
    assert_dialog_handled(session, "dismiss #2")

    create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
    result = set_window_rect(session, {
        "x": int(original["x"]),
        "y": int(original["y"])
    })
    assert_success(result)
    assert_dialog_handled(session, "dismiss #3")
示例#17
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")
def test_get_window_rect_prompt_accept(new_session):
    # Step 2
    _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
    session.url = inline("<title>WD doc title</title>")

    create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
    result = session.transport.send("GET",
                                    "session/%s/window/rect" % session.session_id)
    assert result.status == 200
    assert_dialog_handled(session, "dismiss #1")

    create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
    result = session.transport.send("GET",
                                    "session/%s/window/rect" % session.session_id)
    assert result.status == 200
    assert_dialog_handled(session, "dismiss #2")

    create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
    result = session.transport.send("GET",
                                    "session/%s/window/rect" % session.session_id)
    assert result.status == 200
    assert_dialog_handled(session, "dismiss #3")