0

我是 AngularJS 的新手。我正在尝试使用 Protractor 运行端到端测试。目前,我正在 grunt-protractor-runner 的帮助下从 grunt 运行我的测试。我的基本测试如下所示:

describe('My Tests', function () {
    var p = protractor.getInstance();

    beforeEach(function () {
    });

    it('My First Test', function () {
        var message = "Hello!";
        expect(message).toEqual('Hello!');
    });
});

这工作得很好。但是,它真的没有测试我的应用程序。为此,我总是想从应用程序的根目录开始。为了做到这一点,我已将上述内容更新为以下内容:

describe('My Tests', function () {
    var p = protractor.getInstance();

    beforeEach(function () {
        p.get('#/');
    });

    it('My First Test', function () {
        var message = "Hello!";
        expect(message).toEqual('Hello!');
    });
});

运行此测试时,Chrome 会启动。但是,“about:blank”是地址栏中加载的内容。我的应用永远不会加载。我查看了我的 protractor.config.js 文件,它看起来是正确的。它如下所示:

exports.config = {
    allScriptsTimeout: 110000,

    seleniumServerJar: './node_modules/protractor/bin/selenium/selenium-server-standalone-2.37.0.jar',
    seleniumPort: 1234,
    seleniumArgs: [],
    seleniumAddress: null,

    chromeDriver: './node_modules/protractor/bin/selenium/chromedriver.exe',
    capabilities: { 'browserName': 'chrome' },

    specs: [ '../tests/**/*.spec.js' ],

    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000
    }
};

为了通过量角器进行集成测试,如何让我的应用程序加载到 Chrome 中?

4

1 回答 1

1

也许您已经想出了如何让它工作,但如果没有,以下可能会有所帮助(当然,如有必要修改端口):

// A base URL for your application under test. Calls to protractor.get()
// with relative paths will be prepended with this.
baseUrl: 'http://localhost:3000'

将此属性添加到您的 protractor.config.js 文件中。

参考:https ://github.com/angular/protractor/blob/master/referenceConf.js

于 2014-01-06T02:57:22.230 回答