Skip to content

feat(locator): add press, focus, doubleClick and rightClick (#134) - #188

Merged
shossain786 merged 5 commits into
seleniumboot:masterfrom
TONGdamy:feat/locator-actions-134
Oct 21, 2026
Merged

shossain786 merged 5 commits into
seleniumboot:masterfrom
TONGdamy:feat/locator-actions-134

Conversation

@TONGdamy

Copy link
Copy Markdown
Contributor

What & why

Locator had no doubleClick(), rightClick(), focus() or press(Keys...), so tests had to drop back to BasePage or raw WebDriver for these interactions. This PR adds all four so the Locator API is the only place users need to look.

All four are terminal actions and follow the contract from #67/#68: the locator is re-resolved from scratch on every poll, and stale or not-yet-present elements are retried until timeouts.explicit. A StaleElementReferenceException thrown while the action is performed is retried as well, so a stale reference is never treated as success.

  • doubleClick() waits for the element to be visible and enabled, like click() and BasePage.doubleClick().
  • rightClick() waits for the element to be visible, like hover() and BasePage.rightClick().
  • press(Keys...) sends the keys to the element without clearing it.
  • focus() moves focus to the element with JavaScript.

Closes #134.

Type of change

  • Bug fix
  • New feature (opt-in, aligned with the framework philosophy)
  • Documentation
  • Internal refactor / test coverage

Checklist

  • All existing tests pass (mvn clean verify) (mvn clean verify -Dgpg.skip; GPG signing skipped locally)
  • New behaviour is covered by unit tests
  • No new external dependencies introduced without prior discussion
  • Code follows existing conventions (no new frameworks, minimal abstraction)
  • No breaking changes to @SeleniumBootApi public APIs (or a major version bump is justified below)
  • Docs updated if user-facing behaviour changed (docs-site/)

Notes for reviewers

Commits. The change is split into five commits: doubleClick()/rightClick(), their tests, press(Keys...)/focus(), their tests, and the docs (a changelog entry in docs-site/docs/changelog.md and one line in the locators guide).

Tests. The new LocatorActionsTest runs all four actions through a shared data provider covering eight scenarios: a ready element, an element that appears later, an element that is hidden at first, staleness during the readiness check, staleness during the action, an element that never appears, an element that stays stale (it must time out instead of succeeding), and an element that never becomes visible. A separate test checks that doubleClick() waits until the element is enabled. For the pointer actions, the tests also decode the captured gesture to check the target element, the number of press/release pairs and the mouse button. The tests are in their own file, following LocatorDragToTest.

Verification. mvn clean verify -Dgpg.skip on the branch rebased onto the current master (748d9b6), macOS: BUILD SUCCESS, with 789 tests run and 0 failures, 0 errors and 0 skipped. That is 756 existing tests plus the 33 new LocatorActionsTest tests. The Javadoc jar for the new methods also builds without errors.

Co-authored by @crystalmountain666 and @TONGdamy.

crystalmountain666 and others added 5 commits October 21, 2026 16:03
BasePage already offers doubleClick/rightClick, but Locator did not,
so users had to drop out of the Locator API for these gestures.

Both methods perform the gesture with Selenium's Actions API and go
through the existing terminal-action helpers, so they follow the same
contract as click() and hover() (seleniumboot#67/seleniumboot#68): the element is re-resolved
from scratch on every poll, and stale or not-yet-present elements are
retried until timeouts.explicit. A StaleElementReferenceException
thrown while the gesture is performed is retried as well, rather than
being treated as success.

- doubleClick() waits for the element to be visible and enabled,
  like click().
- rightClick() waits for the element to be visible, like hover().

Each method has Javadoc with a usage example. Tests follow in the
next commit.

Refs seleniumboot#134
…eleniumboot#134)

Add LocatorActionsTest, which checks that doubleClick() and
rightClick() honour the same terminal-action contract as click()
(seleniumboot#67/seleniumboot#68). The tests mock the driver as Interactive so the Actions
sequences can be captured, and set timeouts.explicit to 1s to keep
the timeout cases fast.

Each pointer action is run through a shared data provider covering:

- a ready element: the gesture is performed once on one lookup, and the element is never cleared or plain-clicked
- an element that appears later: the locator re-resolves first
- an element that is hidden at first: the action waits for it to become visible
- an element that goes stale during the readiness check: a fresh element is resolved and used
- an element that goes stale during the gesture: the gesture is retried on a freshly resolved element
- an element that never appears: LocatorException with a TimeoutException cause, and no gesture is performed
- an element that stays stale during the gesture: the action times out instead of reporting success
- an element that never becomes visible: times out without acting

A separate test checks that doubleClick() waits until the element is enabled. The successful cases also decode the captured gesture to check the target element, the number of press/release pairs (2 for doubleClick, 1 for rightClick) and the mouse button (left for doubleClick, right for rightClick).

The data provider is shared so that the keyboard and focus actions can be added to the same matrix.

Refs seleniumboot#134
@shossain786
shossain786 merged commit fb434b4 into seleniumboot:master Oct 21, 2026
2 checks passed
@shossain786

Copy link
Copy Markdown
Contributor

Merged, thank you @TONGdamy and @crystalmountain666. Clean implementation, and the tests cover the stale-element retry contract well. This closes #134.

shossain786 added a commit that referenced this pull request Oct 21, 2026
Bump version across pom, README, docs-site; cut the 3.9.0 changelog and add missing entries (#188, #185, #186, #171, deps).

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

feat(locator): press, focus, doubleClick, rightClick

3 participants