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
Contributor

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.

Rebased on #2480; widget interceptors created for interface fields use the configured default LocatorGroupStrategy.

@mykola-mokhnach

mykola-mokhnach commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

@Ganesh2325 please resolve conflicts in the PR

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.
@cursor
cursor Bot force-pushed the cursor/overridden-widget-interfaces-407e branch from 30688b0 to 336d165 Compare November 3, 2026 06:31
@Ganesh2325

Copy link
Copy Markdown
Contributor Author

@mykola-mokhnach Thanks, conflicts are resolved. I rebased onto the latest master. The conflicts were with #2480 (default LocatorGroupStrategy), and both changes are kept: interface-typed @OverrideWidget fields and list items now also receive the decorator's defaultLocatorGroupStrategy. ./gradlew test checkstyleMain checkstyleTest javadoc passes locally (230 java-client + 12 selenium-bridge tests). Could you please approve the workflows when you get a chance?

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

2 participants