admin管理员组文章数量:1415145
I am testing my Ionic app.
In one page, the button to be clicked is out of the bounds of the window. Hence the following code:
element.all(by.css('.item.item-plex')).get(9).click();
throws the error:
ElementNotVisibleError: element not visible
Hence, I am trying to scroll down the page to make the button visible in page and then try emulating the click on it. I am using the following code:
browser.executeScript('window.scrollTo(0, 200);').then(function() {
element.all(by.css('.item.item-plex')).get(9).click();
expect(browser.getTitle()).toEqual('Vegeta The Prince');
});
But the scrolling is not happening with the above code. Please help!
I am using Google Chrome.
I am testing my Ionic app.
In one page, the button to be clicked is out of the bounds of the window. Hence the following code:
element.all(by.css('.item.item-plex')).get(9).click();
throws the error:
ElementNotVisibleError: element not visible
Hence, I am trying to scroll down the page to make the button visible in page and then try emulating the click on it. I am using the following code:
browser.executeScript('window.scrollTo(0, 200);').then(function() {
element.all(by.css('.item.item-plex')).get(9).click();
expect(browser.getTitle()).toEqual('Vegeta The Prince');
});
But the scrolling is not happening with the above code. Please help!
I am using Google Chrome.
Share Improve this question edited Jun 9, 2015 at 21:01 alecxe 475k127 gold badges1.1k silver badges1.2k bronze badges asked Jun 9, 2015 at 16:45 saiy2ksaiy2k 1,8621 gold badge23 silver badges43 bronze badges2 Answers
Reset to default 4When I encounter issues like this, I scroll into view:
var elm = element.all(by.css('.item.item-plex')).get(9);
browser.executeScript("arguments[0].scrollIntoView();", elm.getWebElement());
elm.click();
I solved this issue using
window.scrollTo(x, y)
code:
var elm = element.all(by.css('.item.item-plex')).get(9);
elm.getLocation()
.then(function (location) {
return browser.executeScript('window.scrollTo(' + location.x + ', ' + location.y + ');')
})
.then(function () {
return elm.click();
})
})
本文标签: javascriptProtractor scrolling through executeScript not workingStack Overflow
版权声明:本文标题:javascript - Protractor scrolling through executeScript not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745217959a2648258.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论