放在哪里implicitlyWait在量角器? [英] Where to put implicitlyWait in Protractor?

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

问题描述

如果我想使用 implicitlyWait ,在那里我应该把 browser.manage()超时()implicitlyWait(5000);
在测试?

If I want to use implicitlyWait, where I should put browser.manage().timeouts().implicitlyWait(5000); in the test?

推荐答案

添加它在上prepare()您量角器的conf.js文件的功能。之所以要添加<一个href=\"https://angular.github.io/protractor/#/api?view=webdriver.WebDriver.Timeouts.prototype.implicitlyWait\"相对=nofollow> implicitlyWait() 存在是因为它是默认的时间量角器传球和抛出一个错误执行操作前等待。让量角器知道隐含的等待时间是什么,测试开始之前,即使是最好的办法。

Add it in the onPrepare() function of your protractor's conf.js file. The reason to add implicitlyWait() there is because, it is the default time that protractor waits before passing and throwing an error for performing an action. Letting protractor know what the implicit wait time is, even before the tests start is the best way.

示例场景:

假设你有下面的行code的 -

Suppose you have the below line of code -

element(LOCATOR).getText();

在您的测试规范和量角器启动页面上的自动化后执行。现在,如果指定了定位的元素不是在页面上找到,那么量角器不立即抛出一个错误,但它等待等待时间来完成。与此同时,直到隐超时,它会检查元件可以被设置了DOM。如果在年底等待时间因素没有找到,那么抛出量角器各自的错误。

in your test spec and protractor executes it after initiating the automation on page. Now, if the element with the locator specified is not found on the page, then protractor doesn't throw an error immediately, but it waits for the implicit wait time to complete. Meanwhile until implicit timeouts, it checks if the element can be located on the DOM. If at the end of the implicit wait time the element is not found, then the protractor throws the respective error.

用法:

onPrepare: function(){
    browser.manage().timeouts().implicitlyWait(5000);
},

这篇关于放在哪里implicitlyWait在量角器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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