量角器:向下滚动 [英] Protractor: Scroll down

查看:190
本文介绍了量角器:向下滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面上有一个按钮,当用户向下滚动时可以看到该按钮。因此,量角器测试给出了一个错误:

I have an button on my page that is visible when the user scrolls down. Because of this, protractor tests give me an error:


UnknownError:未知错误:元素在点(94,188)处无法点击。

UnknownError: unknown error: Element is not clickable at point (94, 188).

我尝试使用:

browser.executeScript('window.scrollTo(0,document.body.scrollHeight)');

当我在量角器elementexplorer.js中进行测试时有效,但在我的常规测试中它不做任何东西。还有其他方法?

which worked when I tested it in protractors elementexplorer.js but in my regular tests it doesn't do anything. Any other way around this?

推荐答案

你需要等待承诺得到解决。以下示例来自公开问题

you need to wait for the promise to be solved. the following example comes from an open issue

browser.executeScript('window.scrollTo(0,0);').then(function () {
    page.saveButton.click();
})

更新
这是一个旧问题(2014年5月),但仍然有一些访客。
澄清: window.scrollTo(0,0)滚动到当前页面的左上角。

Update: This is an old question (May of 2014), but it still gets some visitors. To clarify: window.scrollTo(0, 0) scrolls to the top left corner of the current page.

如果你想滚动到页面的底部你可以调用

If you want to scroll to the buttom of your page you could call

window.scrollTo(0,document.body.scrollHeight )@jsuser在 this中提到的

回答

更现代的方法是使用

浏览器。 actions()。mouseMove(element).perform();

这个答案

这篇关于量角器:向下滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆