scrollIntoView
Scroll element into viewport (MDN Reference).
Usage
$(selector).scrollIntoView(scrollIntoViewOptions)
Parameters
| Name | Type | Details |
|---|---|---|
scrollIntoViewOptions | object, boolean | options for Element.scrollIntoView() (default: { block: 'start', inline: 'nearest' }) |
Example
scrollIntoView.js
it('should demonstrate the scrollIntoView command', async () => {
const elem = await $('#myElement');
// scroll to specific element
await elem.scrollIntoView();
// center element within the viewport
await elem.scrollIntoView({ block: 'center', inline: 'center' });
});