phantomjs如何与量角器一起工作?

时间:2014-10-15 11:46:54

标签: windows angularjs phantomjs protractor

我正在探索量角器和幻影。测试看起来像这样,它可以正常使用 只是铬:

describe('angularjs homepage', function () {
    beforeEach(function () {
        browser.driver.manage().window().setSize(1124, 850);
    });

    it('should greet the named user', function () {
        browser.driver.get('https://angularjs.org/');

        element(by.model('yourName')).sendKeys('Julie');

        var greeting = element(by.binding('yourName'));

        expect(greeting.getText()).toEqual('Hello Julie!');
    });
});

protractor.config看起来像这样:

// An example configuration file.
exports.config = {
    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        'browserName': 'phantomjs',
        'phantomjs.binary.path': 'C:/ptor_testing/node_modules/phantomjs/lib/phantom/phantomjs.exe'
    },


    // For speed, let's just use the Chrome browser.
    //chromeOnly: true,

    // Spec patterns are relative to the current working directly when
    // protractor is called.
    specs: ['example.spec.js'],

    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        // onComplete will be called just before the driver quits.
        onComplete: null,
        // If true, display spec names.
        isVerbose: true,
        // If true, print colors to the terminal.
        showColors: true,
        // If true, include stack traces in failures.
        includeStackTrace: true,
        // Default time to wait in ms before a test fails.
        defaultTimeoutInterval: 30000
    },
    seleniumAddress: 'http://localhost:4444/wd/hub'
};

当我跑步时,我得到:

   Error: Error while waiting for Protractor to sync with the page: {"message":"Can't find variable: angular","name":"ReferenceError","line":4,"stack":"ReferenceError: Can't find variable: angular\n    at :4\n    at anonymous (:13)\n    at Na (phantomjs://webpage.evaluate():14)\n    at phantomjs://webpage.evaluate():15\n    at phantomjs://webpage.evaluate():15\n    at phantomjs://webpage.evaluate():16\n    at phantomjs://webpage.evaluate():16\n    at phantomjs://webpage.evaluate():16","stackArray":[{"sourceURL":"","line":4},{"sourceURL":"","line":13,"function":"anonymous"},{"sourceURL":"phantomjs://webpage.evaluate()","line":14,"function":"Na"},{"sourceURL":"phantomjs://webpage.evaluate()","line":15},{"sourceURL":"phantomjs://webpage.evaluate()","line":15},{"sourceURL":"phantomjs://webpage.evaluate()","line":16},{"sourceURL":"phantomjs://webpage.evaluate()","line":16},{"sourceURL":"phantomjs://webpage.evaluate()","line":16}],"sourceId":81819056}

我该如何解决这个问题?

0 个答案:

没有答案