Update web-platform-tests to revision 8a2ceb5f18911302b7a5c1cd2791f4ab50ad4326

This commit is contained in:
Josh Matthews 2017-10-12 09:25:50 -04:00
parent 462c272380
commit 1f531f66ea
5377 changed files with 174916 additions and 84369 deletions

View file

@ -0,0 +1,59 @@
import pytest
from tests.support.asserts import assert_error, assert_success
from tests.support.inline import inline
def find_element(session, using, value):
return session.transport.send("POST",
"session/%s/element" % session.session_id,
{"using": using, "value": value})
# 12.2 Find Element
@pytest.mark.parametrize("using", ["a", True, None, 1, [], {}])
def test_invalid_using_argument(session, using):
# Step 1 - 2
response = find_element(session, using, "value")
assert_error(response, "invalid argument")
@pytest.mark.parametrize("value", [None, [], {}])
def test_invalid_selector_argument(session, value):
# Step 3 - 4
response = find_element(session, "css selector", value)
assert_error(response, "invalid argument")
def test_closed_context(session, create_window):
# Step 5
new_window = create_window()
session.window_handle = new_window
session.close()
response = find_element(session, "css selector", "foo")
assert_error(response, "no such window")
@pytest.mark.parametrize("using,value",
[("css selector", "#linkText"),
("link text", "full link text"),
("partial link text", "link text"),
("tag name", "a"),
("xpath", "//a")])
def test_find_element(session, using, value):
# Step 8 - 9
session.url = inline("<a href=# id=linkText>full link text</a>")
response = find_element(session, using, value)
assert_success(response)
@pytest.mark.parametrize("using,value", [("css selector", "#wontExist")])
def test_no_element(session, using, value):
# Step 8 - 9
response = find_element(session, using, value)
assert_error(response, "no such element")

View file

@ -0,0 +1,59 @@
import pytest
from tests.support.asserts import assert_error, assert_success
from tests.support.inline import inline
def find_element(session, element, using, value):
return session.transport.send("POST",
"session/%s/element/%s/element" % (session.session_id, element),
{"using": using, "value": value})
@pytest.mark.parametrize("using", ["a", True, None, 1, [], {}])
def test_invalid_using_argument(session, using):
# Step 1 - 2
response = find_element(session, "notReal", using, "value")
assert_error(response, "invalid argument")
@pytest.mark.parametrize("value", [None, [], {}])
def test_invalid_selector_argument(session, value):
# Step 3 - 4
response = find_element(session, "notReal", "css selector", value)
assert_error(response, "invalid argument")
def test_closed_context(session, create_window):
# Step 5
new_window = create_window()
session.window_handle = new_window
session.close()
response = find_element(session, "notReal", "css selector", "foo")
assert_error(response, "no such window")
@pytest.mark.parametrize("using,value",
[("css selector", "#linkText"),
("link text", "full link text"),
("partial link text", "link text"),
("tag name", "a"),
("xpath", "//a")])
def test_find_element(session, using, value):
# Step 8 - 9
session.url = inline("<div><a href=# id=linkText>full link text</a></div>")
element = session.find.css("div", all=False)
response = find_element(session, element.id, using, value)
assert_success(response)
@pytest.mark.parametrize("using,value",[("css selector", "#wontExist")])
def test_no_element(session, using, value):
# Step 8 - 9
session.url = inline("<div></div>")
element = session.find.css("div", all=False)
response = find_element(session, element.id, using, value)
assert_error(response, "no such element")

View file

@ -0,0 +1,58 @@
import pytest
from tests.support.asserts import assert_error, assert_success
from tests.support.inline import inline
def find_elements(session, element, using, value):
return session.transport.send("POST",
"session/%s/element/%s/elements" % (session.session_id, element),
{"using": using, "value": value})
@pytest.mark.parametrize("using", [("a"), (True), (None), (1), ([]), ({})])
def test_invalid_using_argument(session, using):
# Step 1 - 2
response = find_elements(session, "notReal", using, "value")
assert_error(response, "invalid argument")
@pytest.mark.parametrize("value", [None, [], {}])
def test_invalid_selector_argument(session, value):
# Step 3 - 4
response = find_elements(session, "notReal", "css selector", value)
assert_error(response, "invalid argument")
def test_closed_context(session, create_window):
# Step 5
new_window = create_window()
session.window_handle = new_window
session.close()
response = find_elements(session, "notReal", "css selector", "foo")
assert_error(response, "no such window")
@pytest.mark.parametrize("using,value",
[("css selector", "#linkText"),
("link text", "full link text"),
("partial link text", "link text"),
("tag name", "a"),
("xpath", "//a")])
def test_find_elements(session, using, value):
# Step 8 - 9
session.url = inline("<div><a href=# id=linkText>full link text</a></div>")
element = session.find.css("div", all=False)
response = find_elements(session, element.id, using, value)
assert_success(response)
@pytest.mark.parametrize("using,value", [("css selector", "#wontExist")])
def test_no_element(session, using, value):
# Step 8 - 9
session.url = inline("<div></div>")
element = session.find.css("div", all=False)
response = find_elements(session, element.id, using, value)
assert response.body["value"] == []

View file

@ -0,0 +1,60 @@
import pytest
from tests.support.asserts import assert_error, assert_success
from tests.support.inline import inline
def find_elements(session, using, value):
return session.transport.send("POST",
"session/%s/elements" % session.session_id,
{"using": using, "value": value})
@pytest.mark.parametrize("using", ["a", True, None, 1, [], {}])
def test_invalid_using_argument(session, using):
# Step 1 - 2
response = find_elements(session, using, "value")
assert_error(response, "invalid argument")
@pytest.mark.parametrize("value", [None, [], {}])
def test_invalid_selector_argument(session, value):
# Step 3 - 4
response = find_elements(session, "css selector", value)
assert_error(response, "invalid argument")
def test_closed_context(session, create_window):
# Step 5
new_window = create_window()
session.window_handle = new_window
session.close()
response = session.transport.send("POST",
"session/%s/elements" % session.session_id,
{"using": "css selector", "value": "foo"})
assert_error(response, "no such window")
@pytest.mark.parametrize("using,value",
[("css selector", "#linkText"),
("link text", "full link text"),
("partial link text", "link text"),
("tag name", "a"),
("xpath", "//a")])
def test_find_elements(session, using, value):
# Step 8 - 9
session.url = inline("<a href=# id=linkText>full link text</a>")
response = find_elements(session, using, value)
assert_success(response)
assert len(response.body["value"]) == 1
@pytest.mark.parametrize("using,value", [("css selector", "#wontExist")])
def test_no_element(session, using, value):
# Step 8 - 9
response = find_elements(session, using, value)
assert_success(response)
assert response.body["value"] == []