Bug 1392984 - Add Find Element From Element wdspec tests r=ato
authorDavid Burns <dburns@mozilla.com>
Wed, 23 Aug 2017 22:27:32 +0100
changeset 430059 3ebe0b1a5fa257d9d25458f339ec62987da6290a
parent 430058 f77826e523e560f46216e3c35dc9841873c05af6
child 430060 9b7b66644b995fb7bae6fd1206901fc8d26ae3c3
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 From Element wdspec tests r=ato This adds wdspec tests for Find Element From Element as in https://w3c.github.io/webdriver/webdriver-spec.html#find-element-from-element MozReview-Commit-ID: 1a4vRv9wuwr
testing/web-platform/tests/webdriver/tests/retrieval/find_element_from_element.py
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/webdriver/tests/retrieval/find_element_from_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, 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")