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

[web] Webdriver can't return shadowRoot (as SearchContext) in Chrome96+ #99775

Open
ditman opened this issue Mar 8, 2022 · 5 comments
Open
Labels
dependency: dart Dart team may need to help us P3 Issues that are less important to the Flutter project platform-web Web applications specifically team-web Owned by Web platform team triaged-web Triaged by Web platform team

Comments

@ditman
Copy link
Member

ditman commented Mar 8, 2022

We're attempting to run some tests in Chrome96, and this bit of the code is failing:

// It's either the shadowRoot within flt-glass-pane, or [driver.webDriver].
final SearchContext appRoot = await driver.webDriver.execute(
'return document.querySelector("flt-glass-pane")?.shadowRoot;',
<dynamic>[],
) as SearchContext? ?? driver.webDriver;

With the following error (complete build):

   type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'SearchContext?' in type cast
   test_driver/smoke_web_engine_test.dart 50:9       main.<fn>.<fn>
   ===== asynchronous gap ===========================
   package:test_api/src/backend/declarer.dart 215:9  Declarer.test.<fn>.<fn>
   ===== asynchronous gap ===========================
   package:test_api/src/backend/declarer.dart 213:7  Declarer.test.<fn>
   ===== asynchronous gap ===========================
   package:test_api/src/backend/invoker.dart 257:7   Invoker._waitForOutstandingCallbacks.<fn>
@ditman ditman added team-infra Owned by Infrastructure team platform-web Web applications specifically and removed team-infra Owned by Infrastructure team labels Mar 8, 2022
@ditman
Copy link
Member Author

ditman commented Mar 8, 2022

It seems that there has been a change in how Chrome 96+ retrieves the shadowRoot of an element.

Looking at the equivalent fix in Selenium, it seems that some of the changes need to happen in package:webdriver?

@ditman ditman changed the title [web] Webdriver can't see shadowRoot in Chrome96+ [web] Webdriver can't return shadowRoot (as SearchContexts) in Chrome96+ Mar 8, 2022
@ditman ditman changed the title [web] Webdriver can't return shadowRoot (as SearchContexts) in Chrome96+ [web] Webdriver can't return shadowRoot (as SearchContext) in Chrome96+ Mar 8, 2022
@ditman
Copy link
Member Author

ditman commented Mar 8, 2022

There might be a workaround by splitting the selection of the element that contains the shadow root, and the retrieval of the shadowRoot itself:

WebElement shadowHost = seleniumWebDriver.findElement(By.cssSelector("#shadowrootcontainer"));
JavascriptExecutor javascriptExecutor = (JavascriptExecutor) seleniumWebDriver;

SearchContext shadowRoot = (SearchContext) javascriptExecutor.executeScript("return arguments[0].shadowRoot", shadowHost);

WebElement shadowContent = shadowRoot.findElement(By.cssSelector("#shadowcontentcss"));

@yjbanov yjbanov added dependency: dart Dart team may need to help us team-ecosystem Owned by Ecosystem team P3 Issues that are less important to the Flutter project labels Mar 10, 2022
@yjbanov
Copy link
Contributor

yjbanov commented Mar 10, 2022

We should copy this issue into the package:webdriver repo, but keep this one open for tracking.

@ditman
Copy link
Member Author

ditman commented Mar 11, 2022

Created google/webdriver.dart#247

@flutter-triage-bot flutter-triage-bot bot added team-web Owned by Web platform team triaged-web Triaged by Web platform team and removed team-ecosystem Owned by Ecosystem team team-web Owned by Web platform team triaged-web Triaged by Web platform team labels Jul 8, 2023
@flutter-triage-bot
Copy link

Issue is assigned to multiple teams (ecosystem, web). Please ensure the issue has only one team-* label at a time. Use fyi-* labels to have another team look at the issue without reassigning it.
The triaged-web label is irrelevant if there is no team-web label or fyi-web label.

@ditman ditman added fyi-ecosystem For the attention of Ecosystem team team-web Owned by Web platform team triaged-web Triaged by Web platform team labels Jul 8, 2023
@stuartmorgan stuartmorgan added the triaged-ecosystem Triaged by Ecosystem team label Jul 13, 2023
@flutter-triage-bot flutter-triage-bot bot removed fyi-ecosystem For the attention of Ecosystem team triaged-ecosystem Triaged by Ecosystem team labels Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency: dart Dart team may need to help us P3 Issues that are less important to the Flutter project platform-web Web applications specifically team-web Owned by Web platform team triaged-web Triaged by Web platform team
Projects
None yet
Development

No branches or pull requests

3 participants