Skip to content

feat(core): Add hover-selector and wait-after-hover configuration options - #2333

Open
yearn-otto wants to merge 2 commits into
mainfrom
feature/hover-element
Open

yearn-otto wants to merge 2 commits into
mainfrom
feature/hover-element

Conversation

@yearn-otto

@yearn-otto yearn-otto commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds support for hovering over an element via Selenium WebDriver's native Actions API before the screenshots of a page are taken.

Simulating a mouse hover via custom JavaScript (dispatchEvent) does not trigger CSS :hover states, because browsers only apply :hover for real input/pointer events. This feature uses Actions.moveToElement().perform(), which sends input events through the browser itself (also in headless mode).

New configuration options

  • hover-selector (String, CSS selector): Selector of the element to hover over. If multiple elements match, the first one is hovered.
  • wait-after-hover (Float, seconds, default 0, valid values 0 to 20): Time to wait after hovering, so CSS transitions/animations can finish. There is no wait if the hover failed.

Behavior

  • The hover happens after page load, javascript, style, remove-selectors, the scroll to the top of the page and the WebKit scrollbar handling (so the layout doesn't shift away from the pointer).
  • The page height is measured after the hover, so i.e. opened dropdowns are included.
  • After the screenshots of a page, the pointer is moved back to 0,0 of the viewport (where it is at the start of a WebDriver session), so the hover doesn't affect the following pages.
  • If the element isn't found or can't be hovered, a warning is logged and the screenshots are taken without hover. With fail-if-selectors-not-found: true, the run fails instead, with separate messages for a missing element and a failed hover.

Known limitations (documented)

  • The element should be visible at the top of the page. Chromedriver scrolls an element outside the viewport into view, so the screenshots don't start at the top of the page.
  • While JLineup scrolls down for the next screenshots, the browser applies :hover to the element under the pointer (verified in headless Chrome), so the hover is only reliable in the first screenshot. max-scroll-height can limit the screenshots to the top of the page.
  • Devices that emulate touch input may not apply :hover styles.

Other changes

  • GraalVM reachability metadata of cli and cli-lambda contains the new getters and builder methods.
  • JobConfig.exampleConfig() and the examples in docs/CONFIGURATION.md contain hover-selector.
  • docs/CONFIGURATION.md: new sections for both options, fail-if-selectors-not-found mentions the hover.
  • HISTORY.md entry.

Verification

  • BrowserTest: hover, null/empty/blank selectors, wait after hover (and no wait after a failed hover), lenient and strict handling of missing elements and failed hovers, order in the screenshot flow (scroll to top → hover → page height → screenshots → pointer reset), pointer reset.
  • UrlConfigTest: JSON/YAML deserialization.
  • ConfigMergerTest: merge precedence.
  • JobConfigValidatorTest: wait-after-hover range.
  • JLineupCLIAcceptanceTest.shouldHoverOverSelectorAndResetPointerForNextPage: real headless Chrome run. A box turns red on hover with a transition; the 'after' page is a static red copy, so the comparison only passes if the hover and the wait worked. A second page with a hoverable box scrolled under the old pointer position must not be hovered.

@MediaMarco MediaMarco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All other wait times in the config are specified in seconds. Also, the unit is not part of the name of other config values. Could we adjust this for consistency reasons?

@yearn-otto
yearn-otto force-pushed the feature/hover-element branch from 5b9e3e8 to 093f38a Compare November 18, 2026 08:12
@yearn-otto yearn-otto changed the title feat(core): Add hover-element and hover-wait-ms configuration options feat(core): Add hover-element and hover-wait configuration options Nov 18, 2026
@MediaMarco MediaMarco changed the title feat(core): Add hover-element and hover-wait configuration options feat(core): Add hover-selector and wait-after-hover configuration options Nov 25, 2026
…ling

Rename hover-element/hover-wait to hover-selector/wait-after-hover to match
the existing option names. Hover after the WebKit scrollbar handling, measure
the page height after hovering and move the pointer back to 0,0 after the
screenshots of a page. Distinguish missing elements from failed hovers and
don't log twice in strict mode.

Add GraalVM reachability metadata, example config, HISTORY entry, documented
limitations, more unit tests and a Chrome acceptance test.

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.

2 participants