2014-09-19 130 views
4

我已經使用運行firefox和chrome的量角器編寫了相當數量的E2E測試,並且所有工作都很好,但是當我嘗試使用phantomjs以便我們可以讓它們在我們的CI服務器與線路故障:使用Chrome/Firefox完成量角器測試但幻像失敗

UnknownError: Error communicating with the remote browser. It may have died. 
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03' 
System info: host: 'referenemesimac.home', ip: '192.168.1.67', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.4', java.version: '1.6.0_65' 
Driver info: driver.version: EventFiringWebDriver 

有沒有人來過這個?這裏是我的protractor.conf.js

exports.config = { 
    // The address of a running selenium server. 
    seleniumAddress: 'http://localhost:4444/wd/hub', 

    // Capabilities to be passed to the webdriver instance. 
    capabilities: { 
    'browserName': 'phantomjs' 
    }, 

    onPrepare: function() { 
    var width = 1440; 
    var height = 900; 
    browser.driver.manage().window().setSize(width, height); 
    }, 

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

    baseUrl: 'http://localhost:3000', 

    // Options to be passed to Jasmine-node. 
    jasmineNodeOpts: { 
    showColors: true, 
    defaultTimeoutInterval: 30000 
    }, 

}; 

回答

2

如前所述here

你應該使用ignoreSynchronization瀏覽器的選項,睡眠()量角器方法,使其工作,這樣的:

// 
// test/e2e/base/registration.js 
// 
'use strict'; 
var $p; 

describe('E2E Registration', function() { 
    beforeEach(function() { 
    $p = protractor.getInstance(); 
    browser.ignoreSynchronization = true; 
    browser.driver.manage().window().setSize(1280, 1024); 
    }); 

    it('should register a user', function() { 
    browser.get('/#/register'); 
    $p.sleep(3000); 
    expect(element(by.css('input.sign-up-button')).isPresent()).toBeTruthy(); 
    element(by.model('user.email')).sendKeys('[email protected]'); 
    element(by.model('user.password')).sendKeys('bar'); 
    element(by.model('user.repeatPassword')).sendKeys('bar'); 
    element(by.cssContainingText('option', 'ITALY')).click(); 
    element(by.css('ins.iCheck-helper')).click(); 
    element(by.css('input.sign-up-button')).click(); 
    $p.sleep(3000); 
    expect($p.getCurrentUrl()).toMatch(/dashboard/i); 
    }); 
}); 

是的,我不喜歡它,但它的工作原理。

希望有人會更好地回答這個問題。

您也可以嘗試更換$ p.sleep()$ p.waitForAngular();,如here所述。

+0

我們決定放下量角器以獲得更穩定的東西。我們現在正在使用水豚 – 2014-12-09 08:47:48

+0

有幾天後,用量角器和phantomjs有了一天的時間,當所有測試都有效時,我開始思考同樣的問題。 – bullgare 2014-12-09 14:37:08