Skip to content

Commit 1f8b0c5

Browse files
whimboodiemol
andauthored
Remove "shadow_root" assertion in Python bindings for Firefox (#11821)
Remove "shadow_root" assertion for Firefox. The "Get Element ShadowRoot" command has been implemented in Firefox 96 (a year ago) and it should no longer cause an assertion. Co-authored-by: Diego Molina <[email protected]>
1 parent 0ccef9a commit 1f8b0c5

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

py/selenium/webdriver/remote/webelement.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,21 +235,20 @@ def send_keys(self, *value) -> None:
235235
@property
236236
def shadow_root(self) -> ShadowRoot:
237237
"""Returns a shadow root of the element if there is one or an error.
238-
Only works from Chromium 96 onwards. Previous versions of Chromium
239-
based browsers will throw an assertion exception.
238+
Only works from Chromium 96 and Firefox 96 onwards. Previous versions
239+
of browsers will throw an assertion exception.
240240
241241
:Returns:
242242
- ShadowRoot object or
243243
- NoSuchShadowRoot - if no shadow root was attached to element
244244
"""
245245
browser_main_version = int(self._parent.caps["browserVersion"].split(".")[0])
246-
assert self._parent.caps["browserName"].lower() not in [
247-
"firefox",
248-
"safari",
249-
], "This only currently works in Chromium based browsers"
246+
assert (
247+
self._parent.caps["browserName"].lower() != "safari"
248+
), "This only currently works in Firefox and Chromium based browsers"
250249
assert (
251250
browser_main_version > 95
252-
), f"Please use Chromium based browsers with version 96 or later. Version used {self._parent.caps['browserVersion']}"
251+
), f"Please use Firefox or Chromium based browsers with version 96 or later. Version used {self._parent.caps['browserVersion']}"
253252
return self._execute(Command.GET_SHADOW_ROOT)["value"]
254253

255254
# RenderedWebElement Items

py/test/selenium/webdriver/common/web_components_tests.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525

2626
@pytest.mark.xfail_safari
27-
@pytest.mark.xfail_firefox
2827
@pytest.mark.xfail_remote
2928
def test_can_get_the_shadow_root_of_an_element(driver, pages):
3029
pages.load("webComponents.html")
@@ -33,7 +32,6 @@ def test_can_get_the_shadow_root_of_an_element(driver, pages):
3332

3433

3534
@pytest.mark.xfail_safari
36-
@pytest.mark.xfail_firefox
3735
@pytest.mark.xfail_remote
3836
def test_no_such_shadow_root_thrown_when_no_shadow_root(driver, pages):
3937
with pytest.raises(NoSuchShadowRootException):
@@ -42,7 +40,6 @@ def test_no_such_shadow_root_thrown_when_no_shadow_root(driver, pages):
4240

4341

4442
@pytest.mark.xfail_safari
45-
@pytest.mark.xfail_firefox
4643
@pytest.mark.xfail_remote
4744
def test_returns_shadow_root_via_execute_script(driver, pages):
4845
pages.load("webComponents.html")

0 commit comments

Comments
 (0)