我有一个问题,该描述与我无法在 angular 2 应用程序中使用量角器识别元素完全匹配,但对我来说,通过在 id 值前添加 # 无法解决问题
这是下面的代码:
When('I select my input box', (callback) => {
let inputbox = element(by.css('#roomWidthInput'));
console.log('inputBox promise set');
var scrpt = "return document.getElementById('roomWidthInput');";
browser.executeScript(scrpt).then(function (text) {
console.log('info', 'Script is: ' + scrpt);
});
inputbox.isPresent().then(function(isElementVisible) {
console.log('hello!');
expect(isElementVisible).to.be.true;
callback();
});
});
控制台日志:
然后它抛出错误:函数在 5000 毫秒后超时。
我也尝试过使用by.id
locator 得到完全相同的结果。
任何帮助将不胜感激,谢谢。
您的问题与 无关protractor can't find element
,这是由于您的步骤定义函数执行持续时间超过了默认超时:5 秒。
您应该按如下方式更改默认超时:
黄瓜3及以上
// supports/timeout.js
var { setDefaultTimeout } = require("cucumber");
setDefaultTimeout(60 * 1000);
黄瓜 2 以上,但低于黄瓜 3
// supports/timeout.js
var {defineSupportCode} = require('cucumber');
defineSupportCode(function({setDefaultTimeout}) {
setDefaultTimeout(60 * 1000);
});
黄瓜 1 及以下
// supports/timeout.js
module.exports = function() {
this.setDefaultTimeout(60 * 1000);
};
在 protractor 中conf.js
,将 timeout.js 添加到ucucumberOpts.require中:
// set allScriptsTimeout to fix asynchronous Angular tasks to finish after 11 seconds
allScriptsTimeout: 600 * 1000,
cucumberOpts: {
require: [
"supports/timeout.js",
]
},
onPrepare: function() {
// add this when page opened by browser.get() is not angular page
browser.ignoreSynchronization = true;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句