How to scroll to element using Nightwatch?

前端 未结 5 2127
[愿得一人]
[愿得一人] 2021-02-19 02:27

I am using nightwatch for e2etesting my app. One of the tests fails because it cannot scroll to the element that it is testing I suspect. Question do I need to scroll or is ther

5条回答
  •  故里飘歌
    2021-02-19 02:47

    In addition an example I used as page object command (be_expand) where my selector was an xpath already used in a element (@be_click):

        be_expand() {
            this.api.execute(function(xpath) {
                function getElementByXpath(path) {
                    return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
                }
                var res = getElementByXpath(xpath);
                res.scrollIntoView(true);
            }, [this.elements.be_click.selector]);
            this.assert.visible('@be_click');
            this.click('@be_click');
            return this;
        }
    

提交回复
热议问题