Scrolls a specific element to its vertical top by setting scrollTop = 0 on the element matched by the given CSS selector. After adjusting the position the step dispatches a scroll event with bubbles: true so that any parent listeners are also notified. This step operates on the element's internal scroll state, not the page window, making it ideal for resetting independently scrollable containers such as sidebars, modals, drawers, or off-canvas panels.
The selector is passed as a double-quoted string and can be any valid CSS selector - IDs, classes, attribute selectors, or compound selectors. The element must exist in the DOM and must be scrollable for the step to have a visible effect; if it is not currently scrolled, setting scrollTop = 0 is a no-op and the test continues without error.
Accepted phrasings
When I scroll to top of "#sidebar"
When we scroll to top of "#off-canvas"
When scrolling to top of "#main-container"
And I scroll to top of ".panel--results"
Examples
When I scroll to top of "#off-canvas"
And we scroll to top of "#sidebar"
When scrolling to top of "#main-container"
And I scroll to top of ".drawer"
In a real scenario
Scenario: Reopening the side panel resets its scroll position
Given I am an anonymous user
When I go to "/catalog"
And I click "Filters"
And I scroll to bottom of "#filter-panel"
And I click "Close"
And I click "Filters"
And I scroll to top of "#filter-panel"
Then I should see "Category" in "#filter-panel"