Skip to content

feat: allow @OverrideWidget fields declared as interfaces - #2486

Open
Ganesh2325 wants to merge 1 commit into
appium:masterfrom
Ganesh2325:cursor/overridden-widget-interfaces-407e
Open

Ganesh2325 wants to merge 1 commit into
appium:masterfrom
Ganesh2325:cursor/overridden-widget-interfaces-407e

Conversation

@Ganesh2325

@Ganesh2325 Ganesh2325 commented Oct 30, 2026 •

Copy link
Copy Markdown

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.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Overridden widget interfaces

1 participant