Reputation: 834
I have written a fair amount of E2E tests using protractor running firefox and chrome and all works well, however when I try to use phantomjs so that we can get them running on our CI server they fail with the line:
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
Has anyone come into this before? Here is my 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
},
};
Upvotes: 4
Views: 1589
Reputation: 1763
As mentioned here:
you should use ignoreSynchronization browser's option and sleep() method of protractor to make it work, like that:
//
// 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);
});
});
Yes, I don't like it, but it works.
Hope someone will answer this question better.
You can also try to replace $p.sleep() with $p.waitForAngular();, as mentioned here.
Upvotes: 2