Tests failing intermittently with shardTestFiles set to true - angularjs

My tests are passing reliably without shardTestFiles, but with shardTestFiles true I am getting intermittent in different places. The error message is the following:
Failed: Error while waiting for Protractor to sync with the page: "Cannot read property '$$testability' of undefined"
This is from my config file:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs : ['tests/e2e/**/*.js'],
rootElement: 'body#rootElement',
capabilities: {
browserName: 'chrome',
shardTestFiles: true,
maxInstances:11
},
allScriptsTimeout: 500000,
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 500000,
isVerbose: true
}
};
How do I get my reliable tests to run reliably with shardTestFiles on?

Related

Timed out waiting for Protractor to synchronize with the page after 11 seconds

I am new to Protractor (can say just 1 day old) and have been trying to run end to end test.
However, every time I run conf.js, I am being displayed with "Timed out waiting for Protractor to synchronize with the page after 11 seconds."
Before posting this question, have tried all options given by other respondents, but still am unable to resolve the issue and thus request your help.
To support, below are the details of my configurations and spec js files:
Conf.js:
exports.config = {
directConnect: true,
capabilities: {'browserName': 'chrome'},
framework: 'jasmine',
specs: ['example_spec.js'],
jasmineNodeOpts: {
defaultTimeoutInterval: 100000
}
};
example_spec.js:
describe('forfirm homepage', function() {
it('login window should open', function() {
browser.get('https://www.forfirm.com');
element(by.model('forfirm.email')).sendKeys('email#email.com');
element(by.model('form.password')).sendKeys('Password');
});
});
Output received:
Failures:
1) forfirm homepage login window should open
Message:
Failed: Timed out waiting for Protractor to synchronize with the page after 11 seconds. Please see https://github.com/angular/protractor/blob/master/docs/faq.md. The following tasks were pending:
- $timeout: function (){a.next(),h=f(j,5e3)}
Stack:
Error: Failed: Timed out waiting for Protractor to synchronize with the page after 11 seconds. Please see https://github.com/angular/protractor/blob/master/docs/faq.md. The following tasks were pending:
- $timeout: function (){a.next(),h=f(j,5e3)}
at /Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/jasminewd2/index.js:101:16
at Promise.invokeCallback_ (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1329:14)
at TaskQueue.execute_ (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2790:14)
at TaskQueue.executeNext_ (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2773:21)
1 spec, 1 failure
Finished in 22.022 seconds
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #01 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
Also, while running the protractor conf.js, I could not see protractor launching Chrome browser.
You should take a look on Timeouts and try to set all of them first
allScriptsTimeout: 120000,
getPageTimeout: 120000,
jasmineNodeOpts: {
defaultTimeoutInterval: 120000
},
Update:
i hate ignoreSynchronization, you should read about it, how to avoid it in official protractor documentation - try this:
conf.js
exports.config = {
directConnect: true,
capabilities: {'browserName': 'chrome'},
framework: 'jasmine',
specs: ['example_spec.js'],
allScriptsTimeout: 120000,
getPageTimeout: 120000,
jasmineNodeOpts: {
defaultTimeoutInterval: 120000
},
onPrepare: function () {
browser.driver.manage().window().maximize();
}};
example_spec.js
describe('forfirm homepage', function() {
it('login window should open', function() {
browser.ignoreSynchronization = true;
browser.get('https://www.forfirm.com');
element(by.model('form.email')).sendKeys('email#email.com');
element(by.model('form.password')).sendKeys('Password');
browser.sleep(5000);
});});
I believe this should solve the issue, as per Protractor official documentation at "https://github.com/angular/protractor/blob/master/docs/timeouts.md".
Interestingly, in our application, I see that this still takes 11 seconds default even though I have set the allScriptsTimeout to a value say 120 seconds.
I tried doing this in OnPrepare too, despite that I am seeing the same time out error stating Protractor synching with the page for 11 seconds. Any thoughts would be highly appreciated.
Below is an example of my config (Node - 4.2.4, Protractor - 3.1.1)
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['DemoTest.js'],
getPageTimeout: 120000,
allScriptsTimeout: 120000,
capabilities: {
browserName: 'chrome',
},
onPrepare: function(){
browser.ignoreSynchronization = true;
getPageTimeout: 120000;
allScriptsTimeout: 120000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 180000;
},
}

Protractor timeout on Jenkins with PhantomJS

I created a Jenkins job to run Protractor tests at midnight.
For headless testing, I'm using PhantomJS browser because I can't install Xvfb (don't have the rights).
I'm running the Protractor tests through a Grunt task.
On my local machine (windows), the grunt job works fine, and the tests pass.
On the server, I'm getting
Failed: waiting for page to load for 10000ms
...
Failed: Error while waiting for Protractor to sync with the page: "window.angular is undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
My protractor-headless.conf:
exports.config = {
directConnect: false,
capabilities: {
browserName: 'phantomjs',
'phantomjs.binary.path': require('phantomjs').path,
'phantomjs.cli.args': []
},
seleniumServerJar: require('selenium-server-standalone-jar').path,
framework: 'jasmine2',
specs: [
'./e2e/**/**.spec.js'
],
allScriptsTimeout: 30000,
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 200000,
isVerbose: true//,
//includeStackTrace : false
},
onPrepare: function() {
'use strict';
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: 'test-results',
filePrefix: 'xmloutput'
}));
}
};
And the Grunt Job:
protractor: {
options: {
configFile: 'src/test/javascript/protractor.conf.js',
keepAlive: true,
noColor: false,
verbose: true,
args: {
// Arguments passed to the command
}
},
headless: {
options: {
keepAlive: false,
configFile: 'src/test/javascript/protractor-headless.conf.js'
}
}
}
...
grunt.registerTask('e2e-test-headless', [
'protractor:headless'
]);
The test have access to the testing environment.
Any idea what can be the problem?

Protractor e2e testing Maximum limit for Multiuser testing

I am writing e2e test cases for my Angular application using protractor.I am trying to generate HTML Reports and multiuser testing. This is my
conf.js :
var HtmlReporter = require('protractor-html-screenshot-reporter');
var reporter=new HtmlReporter({
baseDirectory: '/test/e2e/JasmineReporter', // a location to store screen shots.
docTitle: 'Report',
docName: 'protractor-demo-tests-report.html'
});
exports.config = {
seleniumAddress: 'http://localhost:4441/wd/hub',
multiCapabilities: [{
browserName: 'chrome',
acceptSslCerts: true,
trustAllSSLCertificates: true,
specs: ['first_spec.js']
}, {
browserName: 'chrome',
acceptSslCerts: true,
trustAllSSLCertificates: true,
specs: ['second_spec.js']
}],
maxSessions: 1, //Limits max number of instances
onPrepare: function() {
jasmine.getEnv().addReporter(reporter);
},
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 50000
}
};
Now, it is working fine. It is generating HTML Reports for two specs.
But when I limit the instances using maxSessions: 1 (It opens one browser at a time). It is generating report for last spec. And what is the max number of instances we can run.

Selenium stand-alone-serer and PhantomJS

For the moment, I have a basic angular app, generated by "generator-gulp-angular". In this project, I have 2 tests: 1 karma-test and 1 e2e-test (using protractor). The karma-test wil run without a problem, but with the other, I encounter some issues.
I'm trying to run selenium driver with phantomJS to execute the test, and in Chrome it works, in Firefox not (because of the upgrade), but trying to run the test on phantomJS wil fail. I have already downgraded my selenium stand-alone-server but now, selenium will give the error "driver info: driver.session: unknown". I'm using selenium 2.38 and phantom 1.9.x.
Can somebody tell me what to do? Should I adapt something in the conf-files of phantomJS node-module? Should I downgrade my phantomJS? ...
This is my protractor.conf.js:
exports.config = {
//directConnect: true,
seleniumAddress: 'http://localhost:4444/wd/hub',
baseUrl: 'http://localhost:9292',
rootElement: 'body',
// Capabilities to be passed to the webdriver instance.
capabilities: {
browserName: 'phantomjs',
'phantomjs.binary.path': 'C:/Users/--------/Documents/3de_Academiejaar/Stage/GitHub_Repos/proj_Jesper2/node_modules/phantomjs/bin/phantomjs',
},
specs: [paths.e2e + '/**/*.js'],
framework: 'jasmine',
jasmineNodeOpts: {
onComplete: function () {
},
isVerbose: true,
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 30000
}
};

SSL with Protractor and PhantomJS

I am trying to work PhantomJS with Protractor with the web application being hosted on https. I need to specify a cert in order for this to work. Here is my protractor config file:
exports.config = {
// The address of a running selenium server.
seleniumAddress: 'http://localhost:4444/wd/hub',
// Spec patterns are relative to the location of this config.
specs: [
'spec/*.js',
'spec/**/*.js'
],
capabilities: {
browserName: 'phantomjs',
'phantomjs.cli.args':['--ssl-certificates-path=cert.p12','--ignore-ssl-errors=true']
},
// A base URL for your application under test. Calls to protractor.get()
// with relative paths will be prepended with this.
baseUrl: 'https://localhost:3000',
jasmineNodeOpts: {
onComplete: null,
isVerbose: false,
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 100000
}
};
The result from the terminal is just a lot of:
17:00:56.340 INFO - Executing: [execute script: return window.location.href;, []])
17:00:56.346 INFO - Done: [execute script: return window.location.href;, []]"
There seems to be an acceptSslCerts option that is pushed into the logs but I have no idea how to set it:
[INFO - 2014-09-30T21:00:56.239Z] Session [df2bf1e0-48e4-11e4-a415-8755c19a8d30] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"1.9.7","driverName":"ghostdriver","driverVersion":"1.1.0","platf orm":"mac-unknown-64bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
Protractor itself throws this error:
Error: Error while waiting for Protractor to sync with the page: {"message":"Can't find variable: angular"
Any ideas?

Resources