Fix ShadowRoot issues; enable command line execution of browser-specific unit tests; resolve HtmlUnit personality issues; propagate System properties to Gradle test tasks; upgrade to latest Selenium/HtmlUnitDriver
In this release, I upgraded to the latest releases of Selenium and HtmlUnitDriver (version 4.39.0). I also made several fundamental changes to core functionality to resolve behavioral issues.
NOTE: This release contains breaking changes, which is indicated by increasing the major version number.
I added the garg: prefix to the browserName capabilities specified in HtmlUnit personality objects so these are handled properly in Selenium Grid execution. This takes advantage of a bug fix in HtmlUnit Remote that enables proper matching and configuration of HtmlUnitDriver nodes. I also added a new personality object for the Microsoft Edge browser.
I revised the handling of Gradle project properties to enable execution of the full range of browser-specific unit tests. Note that the browsers property no longer has a default value. This must be specified for any task that triggers unit test execution. For example:
./gradlew clean build -Pbrowsers=htmlunit
I added the ability to override the standard default values for Selenium Foundation settings by specifying their corresponding System properties prefixed with injected. (e.g. - injected.selenium.browser.name). These injected settings are assigned the same precedence as the default values they override, which are lower in precedence than saved properties, with non-prefixed System properties assigned highest precedence. For example:
./gradlew -Dinjected.selenium.context.platform=android clean build -Pbrowsers=chrome
This feature is primarily intended for use by the Selenium Foundation project itself, enabling the browser profiles to specify browser-specific default settings that can be overridden by standard System property values and saved properties.
I added a test-task configuration block in build.gradle that propagates several sets of System properties...
- ... whose names end with
.binary.path - ... whose names begin with
injected.,selenium.,appium.,testng., orjunit.
I resolved some fundamental issues related to the handling of ShadowRoot search contexts.
- ShadowRoot: Add a [shadowRoot] field, using this as the wrapped context:
- Initialize [shadowRoot] in all constructors.
- Override
findElements()andfindElement(), invoking the corresponding methods of [shadowRoot]. - Revise
getWrappedContext()to return [shadowRoot] instead of instantiating a new one each time.
- FirefoxShadowRoot: Do not override
getWrapperContext(), relying on the superclass implementation. - SearchContextUtils: Change argument types of all affected methods from WrapsContext to SearchContext:
buildScriptToLocateElements(no index),buildScriptToLocateElements(with index),getContextType()getContextType(): Remove explicit one-level context unwrapping fromisElementContext()call.isElementContext(): Auto-unwrap the specified context; add exception handling for JSON serialization.
- RobustElementWrapper: Add context unwrapping to
SearchContextUtils.buildScriptToLocateElement()call.
I also included a few other minor updates:
- Parameterize the DetectsLoadCompletion interface so that only ComponentContainer objects are allowed to implement it.
- Enable load completion checks to be performed when items in component collections are instantiated.
- Implement the DetectsLoadCompletion interface in ExamplePage and all example component classes.
- selenium3Deps.gradle: Upgrade to the latest release of WebDriverManager (version 6.3.3).
- WebDriverUtilsTest: Remove browser name override for EdgeDriver from
testBrowserName(). - SeleniumConfig (selenium 4): Remove global dependency context for ChromiumDriver.
- EdgePlugin (selenium 4): Add dependency context for ChromiumDriver.