量角器:在我的测试中正确使用waitReady.js文件 [英] Protractor: Correct use of waitReady.js file in my tests

查看:112
本文介绍了量角器:在我的测试中正确使用waitReady.js文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在整个测试套件中广泛使用browser.wait。在为不同场景管理不同的超时时,它变得令人头疼。我遇到了waitReady函数( https://gist.github.com/elgalu/2939aad2b2e31418c1bb ) ,但我无法在我的代码中使用它。
目录如下所示:(所有文件除了彼此)

We are using browser.wait extensively throughout the entire test suite. It became a headache when managing different timeouts for different scenarios. I came across a waitReady function(https://gist.github.com/elgalu/2939aad2b2e31418c1bb), but I am unable to utilize it in my code. The directory looks like: (all files besides each other) .

├── conf.js
├── main.js
├── waitReady.js

Main.js --->包含所有描述和阻止

Main.js --->Contains all describe and it blocks

    require('./waitReady.js');
    describe(...){
    it{
    code...
expect(element.waitReady()).toBeTruthy();
    };
    });

由于某种原因,代码找不到该函数,我的代码一直没有定义函数未定义错误。我需要在某处初始化吗?

For some reason the code does not find that function and my code keeps getting function not defined error. Do I need to initialize it somewhere?

推荐答案

将导入放入 onPrepare()在你的量角器配置中:

Put the import into the onPrepare() in your protractor config:

onPrepare: function () {
    require('./waitReady.js');
},

这篇关于量角器:在我的测试中正确使用waitReady.js文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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