本文介绍了如何,可以这么说,在每个量角器-spec测试后重新启动或关闭浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am implementing Protractor test for a web app. I have done some google searching but I have come up with zip, I want to every spec that I create to close the browser after it has ran all of the test in that specific spec file and then continue on to the next -spec file, etc. I've things such as using "beforeAll" and "afterAll" but Jasmine doesn't recognize these methods. A point in the right direction would be awesome!

描述('我稍后会把更有意义的东西放在这里:)',function(){

describe('i will put something more meaningful here later :)', 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 () {

});

});

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

browser should then close, and then open back up to run the next spec.

推荐答案

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

Speaking about restarting browser between tests, there is a relevant configuration option:

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

将其设置为 true

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

FYI, Here is the initial feature request:



  • Feature Request: to have an option to restart new browser session between each test case/scenario

beforeAll afterAll 内置于 jasmine-2.x 。要使它们有效,您需要设置中的测试框架:

beforeAll and afterAll are built into jasmine-2.x. To make them work, you need to set jasmine2 as a testing framework in the protractor config:

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






For jasmine-1.x ,有第三方包提供相同的功能。


For jasmine-1.x, there is a third-party jasmine-beforeAll package that provides the same exact functionality.

这篇关于如何,可以这么说,在每个量角器-spec测试后重新启动或关闭浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 23:06