Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some shadow root tests #29924

Merged
merged 7 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tools/webdriver/webdriver/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def __init__(self, session, id):
@classmethod
def from_json(cls, json, session):
uuid = json[ShadowRoot.identifier]
return cls(uuid, session)
return cls(session, uuid)

def send_shadow_command(self, method, uri, body=None):
url = "shadow/{}/{}".format(self.id, uri)
Expand Down Expand Up @@ -786,7 +786,7 @@ class Element(object):
"""
identifier = "element-6066-11e4-a52e-4f735466cecf"

def __init__(self, id, session):
def __init__(self, session, id):
"""
Construct a new web element representation.

Expand All @@ -807,7 +807,7 @@ def __eq__(self, other):
@classmethod
def from_json(cls, json, session):
uuid = json[Element.identifier]
return cls(uuid, session)
return cls(session, uuid)

def send_element_command(self, method, uri, body=None):
url = "element/%s/%s" % (self.id, uri)
Expand Down
10 changes: 5 additions & 5 deletions webdriver/tests/find_element_from_shadow_root/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_detached_shadow_root(session, get_shadow_page):
shadow_root = custom_element.shadow_root
session.refresh()

response = find_element(session, shadow_root.id, "css", "input")
response = find_element(session, shadow_root.id, "css selector", "input")
assert_error(response, "detached shadow root")


Expand All @@ -64,7 +64,7 @@ def test_found_element_equivalence(session, get_shadow_page):
expected = session.execute_script("return arguments[0].shadowRoot.querySelector('input')",
args=(custom_element,))
shadow_root = custom_element.shadow_root
response = find_element(session, shadow_root.id, "css", "input")
response = find_element(session, shadow_root.id, "css selector", "input")
value = assert_success(response)
assert_same_element(session, value, expected)

Expand All @@ -83,7 +83,7 @@ def test_find_element(session, get_shadow_page, using, value):
args=(custom_element,))
shadow_root = custom_element.shadow_root
response = find_element(session, shadow_root.id, using, value)
assert_success(response)
value = assert_success(response)
assert_same_element(session, value, expected)


Expand All @@ -104,7 +104,7 @@ def test_find_element_link_text(session, get_shadow_page, document, value):
shadow_root = custom_element.shadow_root

response = find_element(session, shadow_root.id, "link text", value)
assert_success(response)
value = assert_success(response)
assert_same_element(session, value, expected)


Expand All @@ -126,7 +126,7 @@ def test_find_element_partial_link_text(session, get_shadow_page, document, valu
shadow_root = custom_element.shadow_root

response = find_element(session, shadow_root.id, "partial link text", value)
assert_success(response)
value = assert_success(response)
assert_same_element(session, value, expected)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def find_element(session, shadow_id, using, value):
return session.transport.send(
"POST", "session/{session_id}/shadow/{shadow_id}/element".format(
session_id=session.session_id,
element_id=shadow_id),
shadow_id=shadow_id),
{"using": using, "value": value})


Expand Down
10 changes: 4 additions & 6 deletions webdriver/tests/find_elements_from_shadow_root/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def find_elements(session, shadow_id, using, value):
{"using": using, "value": value})


def test_null_parameter_value(session, http, inline):
session.url = inline("<div><a href=# id=linkText>full link text</a></div>")
def test_null_parameter_value(session, http, get_shadow_page):
session.url = get_shadow_page("<div><a href=# id=linkText>full link text</a></div>")
custom_element = session.find.css("custom-shadow-element", all=False)
shadow_root = custom_element.shadow_root

Expand Down Expand Up @@ -54,15 +54,15 @@ def test_detached_shadow_root(session, get_shadow_page):
shadow_root = custom_element.shadow_root
session.refresh()

response = find_elements(session, shadow_root.id, "css", "input")
response = find_elements(session, shadow_root.id, "css selector", "input")
assert_error(response, "detached shadow root")


def test_find_elements_equivalence(session, get_shadow_page):
session.url = get_shadow_page("<div><input id='check' type='checkbox'/><input id='text'/></div>")
custom_element = session.find.css("custom-shadow-element", all=False)
shadow_root = custom_element.shadow_root
response = find_elements(session, shadow_root.id, "css", "input")
response = find_elements(session, shadow_root.id, "css selector", "input")
assert_success(response)


Expand Down Expand Up @@ -92,7 +92,6 @@ def test_find_elements(session, get_shadow_page, using, value):
def test_find_elements_link_text(session, get_shadow_page, document, value):
# Step 8 - 9
session.url = get_shadow_page("<div><a href=#>not wanted</a><br/>{0}</div>".format(document))
element = session.find.css("div", all=False)
custom_element = session.find.css("custom-shadow-element", all=False)
shadow_root = custom_element.shadow_root
expected = session.execute_script("return arguments[0].shadowRoot.querySelectorAll('a')[1]",
Expand All @@ -119,7 +118,6 @@ def test_find_elements_link_text(session, get_shadow_page, document, value):
def test_find_elements_partial_link_text(session, get_shadow_page, document, value):
# Step 8 - 9
session.url = get_shadow_page("<div><a href=#>not wanted</a><br/>{0}</div>".format(document))
element = session.find.css("div", all=False)
custom_element = session.find.css("custom-shadow-element", all=False)
shadow_root = custom_element.shadow_root
expected = session.execute_script("return arguments[0].shadowRoot.querySelectorAll('a')[1]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def find_elements(session, shadow_id, using, value):
return session.transport.send(
"POST", "session/{session_id}/shadow/{shadow_id}/elements".format(
session_id=session.session_id,
element_id=shadow_id),
shadow_id=shadow_id),
{"using": using, "value": value})


Expand Down
2 changes: 2 additions & 0 deletions webdriver/tests/support/asserts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# WebDriver specification ID: dfn-error-response-data
errors = {
"detached shadow root": 404,
"element click intercepted": 400,
"element not selectable": 400,
"element not interactable": 400,
Expand All @@ -23,6 +24,7 @@
"no such cookie": 404,
"no such element": 404,
"no such frame": 404,
"no such shadow root": 404,
"no such window": 404,
"script timeout": 500,
"session not created": 500,
Expand Down