Repository navigation
feat: allow @OverrideWidget fields declared as interfaces - #2486
Open
Ganesh2325 wants to merge 1 commit into
Open
Ganesh2325 wants to merge 1 commit into
Ganesh2325 wants to merge 1 commit into
Conversation
An @OverrideWidget field may be an interface implemented by the platform widget classes. Calls are proxied to the concrete widget for the current content type.
Ganesh2325
requested review from
SrinivasanTarget,
mykola-mokhnach,
saikrishna321 and
valfirst
as code owners
October 30, 2026 10:11
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change list
Fixes #1926. An @OverrideWidget field, or a List of that field, may be declared as an interface implemented by the platform widget classes. Calls are proxied to the concrete Widget for the current content type. Fields declared as Widget classes, including abstract classes, behave as they do today.
The override class must implement the interface and extend Widget.
A content type with no override stays unresolved until that content is used, then throws InstantiationException.
Locators are still taken from the selected widget class, including class-level @AndroidFindBy and @iOSXCUITFindBy.
An interface that extends WebElement is left to the normal element decorator.
Types of changes
No changes in production code.
Bugfix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to not work as expected)
Details
public interface UsersWidget {
void doWork();
}
public class IosUsersWidget extends Widget implements UsersWidget {
protected IosUsersWidget(WebElement element) {
super(element);
}
@OverRide
public void doWork() {
// iOS behavior
}
}
@findby(id = "users")
@OverrideWidget(iOSXCUITAutomation = IosUsersWidget.class,
androidUIAutomator = AndroidUsersWidget.class,
html = HtmlUsersWidget.class)
UsersWidget widget;
Name a concrete class for every content type the field is used with. A partial override, such as only iOSXCUITAutomation, works on that content and throws InstantiationException on another.
./gradlew test checkstyleMain checkstyleTest javadoc
BUILD SUCCESSFUL in 36s
16 actionable tasks: 12 executed, 4 up-to-date
226 java-client unit tests and 12 selenium-bridge tests passed (0 failures). Checkstyle and Javadoc passed. No device was required.
Open PR #2480 also edits the widget decorator classes. This change is limited to interface fields and does not depend on that locator-strategy work.