webdriver.dart
webdriver.dart copied to clipboard
Webdriver can't return shadowRoot (as SearchContext) in Chrome96+
We're attempting to run some tests in Chrome96, and this bit of the code is failing:
https://github.com/flutter/flutter/blob/5e0cc4cba416866225821c0eaba581ac7c0a712c/examples/hello_world/test_driver/smoke_web_engine_test.dart#L46-L50
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>
It seems that there has been a change in how Chrome 96+ retrieves the shadowRoot of an element.
- Chromedriver issue: https://bugs.chromium.org/p/chromedriver/issues/detail?id=3958
- Documentation + possible workaround: https://titusfortner.com/2021/11/22/shadow-dom-selenium.html
Looking at the equivalent fix in Selenium, it seems that some of the changes need to happen in package:webdriver?
Copied from https://github.com/flutter/flutter/issues/99775