зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1376625 - Add Is Element Selected wdspec tests r=ato
This adds tests for the Is Element Selected section as documented in https://w3c.github.io/webdriver/webdriver-spec.html#is-element-selected MozReview-Commit-ID: HmwOtYlIZLQ --HG-- extra : rebase_source : f9b07023df980e6a8843a3a37be0f220291dfcfa
This commit is contained in:
Родитель
a7ac6c359d
Коммит
24821741be
|
@ -405905,30 +405905,6 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/get_element_attribute.py": [
|
||||
[
|
||||
"/webdriver/tests/get_element_attribute.py",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/get_element_property.py": [
|
||||
[
|
||||
"/webdriver/tests/get_element_property.py",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/get_element_rect.py": [
|
||||
[
|
||||
"/webdriver/tests/get_element_rect.py",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/get_element_tag_name.py": [
|
||||
[
|
||||
"/webdriver/tests/get_element_tag_name.py",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/get_window_rect.py": [
|
||||
[
|
||||
"/webdriver/tests/get_window_rect.py",
|
||||
|
@ -405959,6 +405935,36 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/state/get_element_attribute.py": [
|
||||
[
|
||||
"/webdriver/tests/state/get_element_attribute.py",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/state/get_element_property.py": [
|
||||
[
|
||||
"/webdriver/tests/state/get_element_property.py",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/state/get_element_rect.py": [
|
||||
[
|
||||
"/webdriver/tests/state/get_element_rect.py",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/state/get_element_tag_name.py": [
|
||||
[
|
||||
"/webdriver/tests/state/get_element_tag_name.py",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/state/is_element_selected.py": [
|
||||
[
|
||||
"/webdriver/tests/state/is_element_selected.py",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/state/text/get_text.py": [
|
||||
[
|
||||
"/webdriver/tests/state/text/get_text.py",
|
||||
|
@ -412963,7 +412969,7 @@
|
|||
"testharness"
|
||||
],
|
||||
"XMLHttpRequest/abort-after-send.htm": [
|
||||
"0491be6129a5d78a55d043f3dc0b5322611b9485",
|
||||
"1ec12c1906dd99e9c048925c560ce1b9ac1a4410",
|
||||
"testharness"
|
||||
],
|
||||
"XMLHttpRequest/abort-after-stop.htm": [
|
||||
|
@ -597643,7 +597649,7 @@
|
|||
"testharness"
|
||||
],
|
||||
"intersection-observer/timestamp.html": [
|
||||
"b9bf8d472d7751ec4a1ebee925d12668bedeee7a",
|
||||
"0d57a6abc3c3056f921401f629ab231c458cf4cb",
|
||||
"testharness"
|
||||
],
|
||||
"intersection-observer/unclipped-root.html": [
|
||||
|
@ -626298,22 +626304,6 @@
|
|||
"5ba51b660c7203bba3ada597c2f56fe094358e1f",
|
||||
"wdspec"
|
||||
],
|
||||
"webdriver/tests/get_element_attribute.py": [
|
||||
"6a42b84f48d90cdbe6dba4485f9d368e6b02418d",
|
||||
"wdspec"
|
||||
],
|
||||
"webdriver/tests/get_element_property.py": [
|
||||
"74009c12bf986a0d1e4ab9bc9f60de14cbbb474e",
|
||||
"wdspec"
|
||||
],
|
||||
"webdriver/tests/get_element_rect.py": [
|
||||
"32342cba9762737de327cc8f717fb8316f8f5083",
|
||||
"wdspec"
|
||||
],
|
||||
"webdriver/tests/get_element_tag_name.py": [
|
||||
"63aa430693c8dbadb600f60516990c3c6c5f4933",
|
||||
"wdspec"
|
||||
],
|
||||
"webdriver/tests/get_window_rect.py": [
|
||||
"2d4c13edc4e659af864750d0341c06ff969a687f",
|
||||
"wdspec"
|
||||
|
@ -626342,6 +626332,26 @@
|
|||
"da39a3ee5e6b4b0d3255bfef95601890afd80709",
|
||||
"support"
|
||||
],
|
||||
"webdriver/tests/state/get_element_attribute.py": [
|
||||
"7d531acbe34c1f48f519158f813c5bce88b33259",
|
||||
"wdspec"
|
||||
],
|
||||
"webdriver/tests/state/get_element_property.py": [
|
||||
"2d4e145cd55c6ee0ed69c617c77975e295e56119",
|
||||
"wdspec"
|
||||
],
|
||||
"webdriver/tests/state/get_element_rect.py": [
|
||||
"9bbc24b6ce5c386aa8a71efeb2f9d6e5792f81d8",
|
||||
"wdspec"
|
||||
],
|
||||
"webdriver/tests/state/get_element_tag_name.py": [
|
||||
"ed23abfb5a1e9d3afdf168c722e7b64827c176ec",
|
||||
"wdspec"
|
||||
],
|
||||
"webdriver/tests/state/is_element_selected.py": [
|
||||
"77b93dd58e0fb4f504c94bc39013d6ada59126bc",
|
||||
"wdspec"
|
||||
],
|
||||
"webdriver/tests/state/text/__init__.py": [
|
||||
"da39a3ee5e6b4b0d3255bfef95601890afd80709",
|
||||
"support"
|
||||
|
|
|
@ -0,0 +1,180 @@
|
|||
from tests.support.asserts import assert_error, assert_dialog_handled, assert_success
|
||||
from tests.support.inline import inline
|
||||
from tests.support.fixtures import create_dialog
|
||||
|
||||
|
||||
alert_doc = inline("<script>window.alert()</script>")
|
||||
check_doc = inline("<input id=checked type=checkbox checked/><input id=notChecked type=checkbox/>")
|
||||
option_doc = inline("""<select>
|
||||
<option id=notSelected>r-</option>
|
||||
<option id=selected selected>r+</option>
|
||||
</select>
|
||||
""")
|
||||
|
||||
|
||||
# 13.1 Is Element Selected
|
||||
|
||||
def test_no_browsing_context(session, create_window):
|
||||
# 13.1 step 1
|
||||
session.window_handle = create_window()
|
||||
session.close()
|
||||
|
||||
result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
|
||||
.format(session_id=session.session_id,
|
||||
element_id="foo"))
|
||||
|
||||
assert_error(result, "no such window")
|
||||
|
||||
|
||||
def test_handle_prompt_dismiss(new_session):
|
||||
# 13.1 step 2
|
||||
_, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "dismiss"}})
|
||||
session.url = inline("<input id=foo>")
|
||||
|
||||
create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
|
||||
|
||||
result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
|
||||
.format(session_id=session.session_id,
|
||||
element_id="foo"))
|
||||
|
||||
assert_success(result, "foo")
|
||||
assert_dialog_handled(session, "dismiss #1")
|
||||
|
||||
create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
|
||||
|
||||
result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
|
||||
.format(session_id=session.session_id,
|
||||
element_id="foo"))
|
||||
|
||||
assert_success(result, "foo")
|
||||
assert_dialog_handled(session, "dismiss #2")
|
||||
|
||||
create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
|
||||
|
||||
result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
|
||||
.format(session_id=session.session_id,
|
||||
element_id="foo"))
|
||||
|
||||
assert_success(result, "foo")
|
||||
assert_dialog_handled(session, "dismiss #3")
|
||||
|
||||
|
||||
def test_handle_prompt_accept(new_session):
|
||||
# 13.1 step 2
|
||||
_, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
|
||||
session.url = inline("<input id=foo>")
|
||||
|
||||
create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
|
||||
|
||||
result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
|
||||
.format(session_id=session.session_id,
|
||||
element_id="foo"))
|
||||
|
||||
assert_success(result, "foo")
|
||||
assert_dialog_handled(session, "dismiss #1")
|
||||
|
||||
create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
|
||||
|
||||
result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
|
||||
.format(session_id=session.session_id,
|
||||
element_id="foo"))
|
||||
|
||||
assert_success(result, "foo")
|
||||
assert_dialog_handled(session, "dismiss #2")
|
||||
|
||||
create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
|
||||
|
||||
result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
|
||||
.format(session_id=session.session_id,
|
||||
element_id="foo"))
|
||||
|
||||
assert_success(result, "foo")
|
||||
assert_dialog_handled(session, "dismiss #3")
|
||||
|
||||
|
||||
def test_handle_prompt_missing_value(session, create_dialog):
|
||||
# 13.1 step 2
|
||||
session.url = inline("<input id=foo>")
|
||||
|
||||
create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
|
||||
|
||||
result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
|
||||
.format(session_id=session.session_id,
|
||||
element_id="foo"))
|
||||
|
||||
assert_error(result, "unexpected alert open")
|
||||
assert_dialog_handled(session, "dismiss #1")
|
||||
|
||||
create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
|
||||
|
||||
result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
|
||||
.format(session_id=session.session_id,
|
||||
element_id="foo"))
|
||||
|
||||
assert_error(result, "unexpected alert open")
|
||||
assert_dialog_handled(session, "dismiss #2")
|
||||
|
||||
create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
|
||||
|
||||
result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
|
||||
.format(session_id=session.session_id,
|
||||
element_id="foo"))
|
||||
|
||||
assert_error(result, "unexpected alert open")
|
||||
assert_dialog_handled(session, "dismiss #3")
|
||||
|
||||
|
||||
def test_element_stale(session):
|
||||
# 13.1 step 4
|
||||
session.url = check_doc
|
||||
element = session.find.css("#checked", all=False)
|
||||
session.refresh()
|
||||
result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
|
||||
.format(session_id=session.session_id,
|
||||
element_id=element.id))
|
||||
|
||||
assert_error(result, "stale element reference")
|
||||
|
||||
|
||||
def test_element_checked(session):
|
||||
# 13.1 step 5
|
||||
session.url = check_doc
|
||||
element = session.find.css("#checked", all=False)
|
||||
result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
|
||||
.format(session_id=session.session_id,
|
||||
element_id=element.id))
|
||||
|
||||
assert_success(result, True)
|
||||
|
||||
|
||||
def test_checkbox_not_selected(session):
|
||||
# 13.1 step 5
|
||||
session.url = check_doc
|
||||
element = session.find.css("#notChecked", all=False)
|
||||
result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
|
||||
.format(session_id=session.session_id,
|
||||
element_id=element.id))
|
||||
|
||||
assert_success(result, False)
|
||||
|
||||
|
||||
def test_element_selected(session):
|
||||
# 13.1 step 5
|
||||
session.url = option_doc
|
||||
element = session.find.css("#selected", all=False)
|
||||
result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
|
||||
.format(session_id=session.session_id,
|
||||
element_id=element.id))
|
||||
|
||||
assert_success(result, True)
|
||||
|
||||
|
||||
def test_element_not_selected(session):
|
||||
# 13.1 step 5
|
||||
session.url = option_doc
|
||||
element = session.find.css("#notSelected", all=False)
|
||||
result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
|
||||
.format(session_id=session.session_id,
|
||||
element_id=element.id))
|
||||
|
||||
assert_success(result, False)
|
Загрузка…
Ссылка в новой задаче