All files / webdriverio/src/commands/element scrollIntoView.js

100% Statements 1/1
100% Branches 1/1
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32                                                1x              
/**
 *
 * Scroll element into viewport.
 * https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
 *
 * <example>
    :scrollIntoView.js
    it('should demonstrate the scrollIntoView command', () => {
        const elem = $('#myElement');
        // scroll to specific element
        elem.scrollIntoView();
    });
 * </example>
 *
 * @alias element.scrollIntoView
 * @param {object|boolean=} scrollIntoViewOptions  boolean alignToTop or scrollIntoViewOptions object
 * @uses protocol/execute
 * @type utility
 *
 */
 
import { ELEMENT_KEY } from '../../constants'
 
export default function scrollIntoView (scrollIntoViewOptions = true) {
    return this.parent.execute(/* istanbul ignore next */function (elem, options) {
        elem.scrollIntoView(options)
    }, {
        [ELEMENT_KEY]: this.elementId, // w3c compatible
        ELEMENT: this.elementId // jsonwp compatible
    }, scrollIntoViewOptions)
}