量角器超时

编程入门 行业动态 更新时间:2024-10-28 08:28:56
本文介绍了量角器超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我一直在开发中量角器相当长的一段时间,像许多你自动测试,我碰到它只能与 browser.sleep() -bridge。我不是硬编码的东西,如该风扇,但如果它是一个必要我会的。

I've been developing automated tests in Protractor for quite some time and like many of you, I've run into gaps which can only be crossed with the browser.sleep()-bridge. I'm not a fan of hard coding things such as this but if it's a necessity I will.

我已经开发的测试已经给我带来了一个点,每个 browser.sleep(1000)对我的运行产生重大影响。目前测试正在测试权限的不同账户(128完全相同),这包括登录和注销,同时检查是每个帐户,并没有收到访问。

The tests I've developed have brought me to a point where every browser.sleep(1000) has a major impact on my runtime. The tests are currently testing permissions for different accounts (128 exactly) and this involves logging in and out whilst checking what every account has and has not received access to.

该网站,我测试的是一个纯粹的AngularJS应用当中,在我眼里,应该让 browser.sleep() pcated方法去$ P $既然有准确等到页面相比,满载browser.sleep()A browser.waitForAngular()法这等待一组的时间,如果你的网站是不是那个时候(它发生)中加载,你就会有不一致的测试(没有人喜欢不一致)。

The website I'm testing is a pure AngularJS application which, in my eyes, should make browser.sleep() a deprecated method since there is a browser.waitForAngular() method that accurately waits until the page is fully loaded compared to browser.sleep() which waits a set amount of time and if your website isn't loaded within that time (it happens), you'll have an inconsistent test (nobody likes inconsistency).

研究使我相信, browser.waitForAngular(),因为他们还没有相关AngularJS并没有考虑到动画以及相关耗时的功能,这是在我们的网站上未实现。此外 waitForAngular()基本上等待 $消化, $ HTTP 和 $超时。

Research has led me to believe that browser.waitForAngular() does not take into account animations and related time-consuming features since they're not AngularJS related yet this is not implemented in our website. Also waitForAngular() basically waits for $digest, $http, and $timeout.

什么我问的是阉这是后话这被看作是因为量角器可以接受的损失一般是很大的,还是有我俯瞰的东西在这里?

What I'm asking is wether this is something which is regarded as an acceptable loss since Protractor is great in general or is there something I'm overlooking here?

TL; DR:是否有解决方案在那里,让我们不要满足于 browser.sleep()?

来源:量角器超时文档,超时 - spec.js(量角器文档), Issue909 ,的 Issue279 , Issue92 ,StackQuestion1

推荐答案

如果你能想出一些测试,以确定是否在等待完成什么,你可以使用browser.wait.以从思想从 docsplendid/archives/209 ,则可以通过返回解析为一个承诺的函数真正或假,比如一个使用is$p$psent

If you can devise some sort of test to determine if whatever you're waiting for has completed, you can use browser.wait. Taking ideas from from docsplendid/archives/209, you can pass a function that returns a promise that resolves to true or false, such as one that uses isPresent

browser.wait(function() { return element(by.id('some-element')).isPresent(); }, 1000);

或者如果你有一些更复杂的情况,你可以使用承诺链接:

or if you have some more complicated condition you can use promise chaining:

browser.wait(function() { return element(by.id('some-element')).isPresent().then(function(isPresent) { return !isPresent; }); }, 1000);

和命令流会等待,一边喊传递给功能等待,直到它返回的承诺解析真正。

and the command flow will wait, repeatedly calling the function passed to wait, until the promise it returns resolves to true.

更多推荐

量角器超时

本文发布于:2023-11-22 23:09:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619284.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:量角器

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!