Bug 1392984 - Add Find Element wdspec tests r=ato
authorDavid Burns <dburns@mozilla.com>
Wed, 23 Aug 2017 21:30:51 +0100
changeset 430057 b4f917de7d599724082616fb587016b807876075
parent 430056 f87cf646f2898f14ec21d824320071cf1eb237e2
child 430058 f77826e523e560f46216e3c35dc9841873c05af6
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1392984
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1392984 - Add Find Element wdspec tests r=ato This adds tests for the Find Element command in https://w3c.github.io/webdriver/webdriver-spec.html#find-element MozReview-Commit-ID: Lgezt2pTXcU
testing/web-platform/tests/webdriver/tests/retrieval/__init__.py
testing/web-platform/tests/webdriver/tests/retrieval/find_element.py
new file mode 100644
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/webdriver/tests/retrieval/find_element.py
@@ -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")