量角器测试中的isPresent()实际上有什么作用? [英] what does isPresent() in protractor testing actually do?

查看:64
本文介绍了量角器测试中的isPresent()实际上有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

isPresent()是否提供真实的

  1. 仅当元素存在于页面中

  1. 仅当元素在页面中可见时(向下滚动)

如果仅检查页面中是否存在该元素,则是否还有其他方法仅在该元素可见时提供true.请提供一些输入.

If it checks only the element is present in the page, whether there is any other method to provide true only when the element is visible.Kindly provide some input.

1

加载页面时出现滚动问题.即(加载页面时,它将向下滚动到页面中间)

I had a scrolling problem while loading a page.ie(while loading the page it will scroll down to the middle of my page)

所以我正在使用滚动服务,该服务将从顶部正确加载页面.

So I am using a scroll service which will load the page correctly from the top.

要点是,在使用滚动服务时,量角器测试应该通过而不失败.

The point is while using scroll service the protractor test should pass and fail when not using it.

现在,当使用滚动服务时,所有元素都将可见,我使用isPresent()返回true

Now when using the scroll service all the elements will be visible,I using the isPresent() which is returning true

当不使用滚动服务时,由于向下滚动,某些元素将不可见,但我仍使用isPresent()看不见的相同元素,该元素也返回true.

And when not using the scroll service some elements will not be visible due to scroll down,but still I am using the same element which is not visible with the isPresent() which is also returning true.

推荐答案

isPresent()返回Promise不是 true false .

isPresent() returns a Promise not true or false.

如果要检查是否存在某个元素,则实际上必须查看promise解析为的值:

If you want to check if an element is present, you actually have to look at the value that the promise resolves to:

element(anyFinder).isPresent().then(function(isPresent) {
  if ( isPresent) {
    // The element is present
  } else {
    // The element is not present
  }
});

这篇关于量角器测试中的isPresent()实际上有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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