scrollIntoView
Scroll element into viewport (MDN Reference).
Usage
$(selector).scrollIntoView(scrollIntoViewOptions)
Parameters
Name | Type | Details |
---|---|---|
scrollIntoViewOptions optional | object , boolean | options for Element.scrollIntoView() (default: true ) |
Example
- Asynchronous Mode
- Synchronous Mode
scrollIntoView.js
it('should demonstrate the scrollIntoView command', async () => {
const elem = await $('#myElement');
// scroll to specific element
await elem.scrollIntoView();
});
scrollIntoView.js
it('should demonstrate the scrollIntoView command', () => {
const elem = $('#myElement');
// scroll to specific element
elem.scrollIntoView();
});
caution
Synchronous Mode will depcrecated with Node.js v16. With an update to the underlying Chromium version it became technically impossible to provide the same synchronous behavior. We recommend to start transition to asynchronous command execution. For more information, see our RFC.