繁体   English   中英

如何,可以这么说,在每个量角器-spec测试后重新启动或关闭浏览器

[英]How to, so to speak, restart or close browser after every protractor -spec test

我正在为Web应用程序实施Protractor测试。 我已经做了一些谷歌搜索,但我已经提出了zip,我希望我创建的每个规范关闭浏览器后,它在该特定的spec文件中运行所有测试,然后继续到下一个-spec文件,我有使用“beforeAll”和“afterAll”之类的东西,但Jasmine不承认这些方法。 正确方向上的一点会很棒!

describe('我将在后面写一些更有意义的东西:)',function(){

//not sure if this method actually exist in Jasmine
afterAll(function () {
   //restart browser or something of the nature
});

it('should do stuff', function () {

});

it('do stuff', function () {

});

});

然后浏览器应该关闭,然后打开备份以运行下一个规范。

谈到在测试之间重新启动浏览器,有一个相关的配置选项:

// If true, protractor will restart the browser between each test.
// CAUTION: This will cause your tests to slow down drastically.
restartBrowserBetweenTests: false,

将其设置为true

仅供参考,这是最初的功能要求:


beforeAllafterAll内置于jasmine-2.x 要使它们工作,您需要将jasmine2设置 量角器配置中 的测试框架

exports.config = {
    ...
    framework: 'jasmine2',
    ...
}

对于jasmine-1.x ,有一个第三方jasmine-beforeAll包提供相同的功能。

在protractor.conf.js中:

capabilities:{
    'shardTestFiles': true,
    'maxInstances': 1
}

这将使用每个.spec文件打开和关闭浏览器,但您可能会丢失标准插件的一些报告功能。 如果shardTestFiles为false,它将打开浏览器,运行onPrepare,串行运行所有测试,然后关闭浏览器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM