I have the following tests, which run fine when I run them locally and on sauce (at least most of the time) using firefox and chrome.
ptor = protractor.getInstance();
baseUrl = protractor.getInstance().params.sBaseUrl;
aRequiredTextFieldsKeys = [
'sFirstName',
'sLastName',
'sStreet',
'sZip',
'sCity'
];
describe('form', function ()
{
var sFormUrl = baseUrl + '#/form';
beforeEach(function ()
{
ptor.get(sFormUrl);
});
describe('wholeForm', function ()
{
it('fully filled form => required fields have correct class && submit leads to other route', function ()
{
function checkRequiredClass(el)
{
expect(el.getAttribute('class')).toContain('ng-valid-required');
}
// requried text-fields
for (var i = 0; i < aRequiredTextFieldsKeys.length; i++) {
var el = element(by.model('oFormData.' + aRequiredTextFieldsKeys[i]));
el.sendKeys('a');
checkRequiredClass(el);
}
// email
var elEmail = element(by.model('oFormData.sEmail'));
elEmail.sendKeys('[email protected]');
checkRequiredClass(el);
// birthday
var elBirthday = element(by.model('oFormData.oBirthday'));
elBirthday.sendKeys('1.1.1995');
checkRequiredClass(el);
// checkboxes
var elCheck1 = element(by.model('oFormData.bAgb'));
elCheck1.click();
checkRequiredClass(elCheck1);
var elCheck2 = element(by.model('oFormData.bPrivatePolicy'));
elCheck2.click();
checkRequiredClass(elCheck2);
// hack upload bon
ptor.executeScript(function ()
{
var scope = $('#application-form-id').scope();
scope.oFormData.bBonUploaded = true;
});
// submit form
element(by.className('btn-submit')).click();
ptor.getCurrentUrl()
.then(function (url)
{
expect(url).toNotBe(sFormUrl);
});
});
});
But when I launch internet explorer or safari, I get all sorts of errors, while the page works fine when tested manually. For IE I get:
Message: UnknownError: JavaScript error (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 97 milliseconds Build info: version: '2.30.0', revision: 'dc1ef9c', time: '2013-02-19 00:15:27' System info: os.name: 'Windows Server 2008 R2', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_35' Session ID: 42b30348-8598-4edb-923e-a7019ced6eb0 Driver info: org.openqa.selenium.ie.InternetExplorerDriver Capabilities [{platform=WINDOWS, elementScrollBehavior=0, javascriptEnabled=true, enablePersistentHover=true, ignoreZoomSetting=false, browserName=internet explorer, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss, version=10, cssSelectorsEnabled=true, ignoreProtectedModeSettings=false, requireWindowFocus=false, allowAsynchronousJavaScript=false, handlesAlerts=true, initialBrowserUrl=, nativeEvents=true, takesScreenshot=true}]
Error: Error while waiting for Protractor to sync with the page: {"stack":"TypeError: Unable to get property 'get' of undefined or null reference\n at Anonymous function (Unknown script code:25:5)\n at Anonymous function (Unknown script code:21:14)\n at Anonymous function (Unknown script code:21:2)","description":"Unable to get property 'get' of undefined or null reference","number":-2146823281}
And for Safari:
UnknownError: Detected a page unload event; script execution does not work across page loads. (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 384 milliseconds Build info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:32:38' System info: os.name: 'Windows Server 2008 R2', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_35' Session ID: null Driver info: org.openqa.selenium.safari.SafariDriver Capabilities [{platform=WINDOWS, javascriptEnabled=true, cssSelectorsEnabled=true, secureSsl=true, browserName=safari, takesScreenshot=true, version=5.1.7}]
I'm confsued about the reasons. I tried simpler tests with the same results, I tried local and remote urls and I tried all sorts of delays like waitForAngular
, wait
and ptor ignoreAsynch = true
. None of them lead to the desired outcome. Any suggestions?
My protractor config file:
// A reference configuration file.
exports.config = {
seleniumServerJar: null,
seleniumPort: null,
chromeOnly: false,
// Additional command line options to pass to selenium. For example,
// if you need to change the browser timeout, use
// seleniumArgs: ['-browserTimeout=60'],
seleniumArgs: [],
sauceUser: 'saucesuer',
sauceKey: 'key',
allScriptsTimeout: 120000,
specs: [
'test/e2e/**/*.js',
],
// https://code.google.com/p/selenium/wiki/DesiredCapabilities
// https://code.google.com/p/selenium/source/browse/javascript/webdriver/capabilities.js
capabilities: {
'browserName': 'phantomjs',
'phantomjs.binary.path':'node_modules/phantomjs/bin/phantomjs'
},
// Selector for the element housing the angular app - this defaults to
// body, but is necessary if ng-app is on a descendant of <body>
rootElement: 'body',
onPrepare: function ()
{
// driver.manage().timeouts().setScriptTimeout(60000);
},
params: {
sBaseUrl: 'https://dev.com/'
},
baseUrl: 'http://localhost:8000',
framework: 'jasmine',
// ----- Options to be passed to minijasminenode -----
//
// See the full list at https://github.com/juliemr/minijasminenode
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: 120000
}
};
WHile it doesnt seem to matter, I use grunt-protractor runner to run multiple instances sequentially.
chrome: {
options: {
args: {
browser: 'chrome',
"idle-timeout": 120
}
}
},
firefox: {
options: {
args: {
browser: 'firefox'
}
}
},
ie9: {
options: {
args: {
browser: 'internet explorer',
version: '9',
"idle-timeout": 120
}
}
},
ie10: {
options: {
args: {
browser: 'internet explorer',
version: '10'
}
}
},
safari7: {
options: {
args: {
browser: 'safari',
version: '7'
}
}
},
safari6: {
options: {
args: {
browser: 'safari',
version: '6'
}
}
},
safari5: {
options: {
args: {
browser: 'safari',
version: '5'
}
}
}
}
grunt.registerTask('e2eall', [
'protractor:ie9',
'protractor:ie10',
'protractor:safari5',
'protractor:safari6',
'protractor:safari7',
'protractor:firefox',
'protractor:chrome'
]);