-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ Run tests on chrome and firefox, skip shadow root test on firefox
- Loading branch information
Showing
6 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from typing import Optional | ||
|
||
from splinter.driver.webdriver import WebDriverElement | ||
from splinter.element_list import ElementList | ||
|
||
from ..decorators import stere_performer | ||
from ..field import Field | ||
|
||
|
||
@stere_performer('null_action', consumes_arg=False) | ||
class ShadowRoot(Field): | ||
"""Field that finds the shadow-root of an element. | ||
Only useful as the root of an Area. | ||
Example: | ||
>>> address_form = Area( | ||
>>> root=ShadowRoot('css', '#addressFormBlock'), | ||
>>> address=Input('css', '#userAddress'), | ||
>>> ) | ||
""" | ||
|
||
def find_all(self, wait_time: Optional[int] = None) -> ElementList: | ||
"""Get the shadowRoot element for any found elements. | ||
Returns: | ||
ElementList | ||
""" | ||
found_elements = self._element.find(wait_time) | ||
|
||
shadow_roots = [] | ||
for elem in found_elements: | ||
shadow_root = self.browser.execute_script( | ||
'return arguments[0].shadowRoot', elem._element, | ||
) | ||
shadow_roots.append(WebDriverElement(shadow_root, elem)) | ||
|
||
return ElementList( | ||
shadow_roots, find_by=self.strategy, query=self.locator, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def skip_by_browser(request): | ||
marker = request.node.get_closest_marker('skip_if_browser') | ||
if marker.args[0] == request.config.option.browser_name: | ||
pytest.skip(marker.args[1]) | ||
|
||
|
||
@pytest.mark.skip_if_browser('firefox', "Can't get shadowRoot in firefox") | ||
def test_shadow_root_find_all(test_page): | ||
"""When I find the shadow root of an element | ||
Then the elements in the shadow root can be found. | ||
""" | ||
test_page.navigate() | ||
assert test_page.shadow_root_area.data.value == 'Inside a shadow root' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters