我刚开始使用Dalekjs,并且尝试打开一个浏览器,运行一些测试,并且(关键)希望保持浏览器窗口打开。
在Dalekjs有办法这样做吗?默认情况似乎是浏览器自动关闭。
module.exports = {
'Page title is correct': function (test) {
test
.open('http://google.com')
.assert.title().is('Google', 'It has title')
.done();
}
};我在控制台中运行时使用:
dalek my-test.js -b chrome发布于 2014-07-21 11:22:42
一旦运行了done函数,它就会根据测试结果运行承诺,并完成测试运行--即关闭任何正在运行的浏览器。
如果要阻止测试并打开窗口,则需要使用wait来睡眠给定的时间,或者使用waitFor等待下一步处理之前满足给定条件。
我建议你采取如下措施:
module.exports = {
'Page title is correct': function (test) {
test
.open('http://google.com')
.assert.title().is('Google', 'It has title')
.execute(function(){
// Save any value from current browser context in global variable for later use
var foo = window.document.getElementById(...).value;
this.data('foo', foo);
})
.waitFor(function (aCheck) {
// Access your second window from here and fetch dependency value
var foo = test.data('foo');
// Do something with foo...
return window.myThing === aCheck;
}, ['arg1', 'arg2'], 10000)
.done();
}
};https://stackoverflow.com/questions/24803581
复制相似问题