I'm trying to run automated tests using Protractor on WebStorm on Chrome and Firefox.
I've set up the environment and everything looks fine unless I'm trying to run it on both Chrome and Firefox. Works perfectly fine on Chrome itself but not on both.
This is my config.js:
exports.config = {
onPrepare: function() {
browser.manage().window().setSize(1600, 1000);
},
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['**/*.spec.*'],
multiCapabilities: [
{
browserName: 'firefox'
},
{
browserName: 'chrome'
}]
};
This is the error I see in the console:
[15:07:02] I/launcher - Running 2 instances of WebDriver
Related
We have a big set of automated tests using Protractor/Jasmine which work like a dream on Azure Pipelines. However, so far we've only used Chrome as the browser.
Now i have to run the same tests using Internet Explorer (11) but am getting no joy at all!!
Here's a part of my conf.js file that deals with the browser:
var HtmlReporter = require('protractor-beautiful-reporter');
var {SpecReporter} = require("jasmine-spec-reporter");
var jasmineReporters = require("jasmine-reporters");
exports.config = {
//seleniumAddress: `http://localhost:4444/wd/hub`,
framework: "jasmine2",
specs: ['specs/secureTrading/01_SecureTrading.js',
'specs/secureTrading/02_ST_Payments.js'
],
getPageTimeout: 40000,
allScriptsTimeout: 60000,
capabilities: {
'browserName': 'internet explorer',
'ignoreProtectedModeSettings': true,
'platform': 'ANY',
'version': '11',
args: ['--silent', '--no-sandbox', '--test-type=browser', '--lang=US', '--start-maximized'], //,'--headless', '--disable-gpu'
prefs: {
'download': {
'prompt_for_download': false,
'directory_upgrade': true,
'extensions_to_open': '',
'default_directory': process.cwd() + '/downloads/'
},
}
},
localSeleniumStandaloneOpts: {
jvmArgs: [
'-Dwebdriver.ie.driver=node_modules/protractor/node_modules/webdriver-manager/selenium/IEDriverServer3.14.0.exe'
]
},
directConnect: false,
seleniumArgs: ['-Dwebdriver.ie.driver=node_modules/protractor/node_modules/webdriver-manager/selenium/IEDriverServer3.14.0.exe'],
ignoreUncaughtExceptions: true,
onPrepare: function() {
Having looked at other postings, I've tried removing // from seleniumAddress:http://localhost:4444/wd/hub,` still errors, Changing DirectConnect makes no difference.
With the settings as above, this is the error message.
Any advice please?
Thanks
Additional Logs as per comment below.
Local:
I am running my protractor tests on browserstack and noticed that the tests I run are marked as separate entries. I want to group them all into a single build.
I have added build capability to my protractor config file. But it doesn't seem to help.
Attaching my protractor configuration field. Appreciate your help.
Thanks
exports.config = {
specs: [
'./src/**/*.e2e-spec.ts'
],
browserstackUser: xx,
browserstackKey: xxx,
multiCapabilities: [{
browserName: 'chrome',
os: 'Windows',
os_version: '10',
'browswestack.debug': true,
project: 'protractor'
}, {
os: 'OS X',
os_version: 'High Sierra',
browserName: 'Safari',
'browswestack.debug': true,
project: 'protractor'
}],
build_number: 'local',
maxInstances: 2,
SELENIUM_PROMISE_MANAGER: false,
directConnect: false,
connectionRetryCount: 3,
connectionRetryTimeout: 90000,
baseUrl: 'http://localhost:4200',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: _.noop
},
onPrepare: () => {
tsNode.register({
project: path.join(__dirname, './tsconfig.e2e.json')
});
let reporter = new SpecReporter();
jasmine.getEnv().addReporter(reporter);
}
};
EDIT : I fixed the problem. I was using build_number instead of build.
However , when I run the tests I noticed that the tests are getting appended. For instance if I run 5 tests , I could only see the last test as executed in browserstack. How should I fix this ?
Open a session on Automate Dashboard and under 'Input Capabilities', check if 'build' is visible.
I'm trying to generate allure report for protractor cucumber but it is not generating any report.
conf.js is as below
exports.config = {
directConnect: true,
capabilities: {
browserName: 'chrome',
},
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
specs: [
'sample.feature'
],
restartBrowserBetweenTests: true,
cucumberOpts: {
require:[
'sampleStep.js',
'reporter.js'
],
},
onPrepare: function () {
browser.manage().window().maximize();
},
};
and the reporter.js file is
var reporter = require('cucumberjs-allure-reporter');
reporter.config(
//targetDir:'./allure-results/'
{ targetDir : './Reports'}
);
module.exports = reporter;
The cucumberjs-allure-reporter library doesn't support higher Cucumber (I can't remember the exact version, maybe only supports Cucumber 2 and lower).
You can try this new library, cucumberjs-allure2-reporter, which is compatible with Cucumber.JS 3+ and Allure 2+.
When running end to end tests with Protractor, I'm seeing promises in my tests being resolved when run with Chrome. But when run with Phantom, the callbacks are never executed, and the test eventually times out with the message Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
My protractor.config.js file looks like:
exports.config = {
baseUrl: 'http://localhost:3000/',
suites: {
// ...
},
directConnect: !(process.env.NODE_ENV === 'CI'),
exclude: [],
multiCapabilities: [{
browserName: process.env.NODE_ENV === 'CI' ? 'phantomjs' : 'chrome',
'phantomjs.cli.args': ['--web-security=false',
'--ignore-ssl-errors=true'
]
}],
allScriptsTimeout: 110000,
getPageTimeout: 100000,
framework: 'jasmine2',
jasmineNodeOpts: {
isVerbose: false,
showColors: true,
includeStackTrace: false,
defaultTimeoutInterval: 400000,
print: function() {}
},
}
With this configuration, a test like the following will execute its callback for Chrome, but not for Phantom:
let targetUrl = '/foo';
it ('should resolve the route properly', function (done) {
browser.getCurrentUrl().then(function (url) {
console.log("****"); // This is printed in Chrome, but not Phantom
expect(url).toContain(targetUrl);
done();
})});
Node Modules Versions
Protractor: 5.0.0
Phantom: 4.0.0
PhantomJS 2.1.7
PhantomJS-prebuilt: 2.1.14
Webdriver Manager (inside Protractor): 11.1.1
Any ideas?
I have 2 test users (will add some more). Some spec files use one and some the other. No 2 test cases can run together if they use the same test user.
I wanted to execute all my specs in a selenium grid. I eventually decided to group the spec files using one spec user with one chrome instance and the other with the other chrome instance. (For now I will be using only one chrome version)
Now the problem is that both chrome browsers are the same version. How do I separate the 2 group of test cases to run in parallel. E.g test user 1 cases will run on Chrome instance 1 and the other set of test cases on Chrome instance 2. I added an arbitrary browser_version to separate the 2 group in the multicapabilities. I dont think it is working.
Is there an elegant solution to this.
For debugging, I tried to get the browser verison a particular test was using with the following lines in the test. Its probably not possible.
(browser.multiCapabilities["browser_version"]).then(function(v){
console.log("check:" + v);
})
;
But it gives the error. Cannot read property 'browser_version' of undefined.
Following is the protractor config file multicapabilities. I dont use "specs" property at the level above this.
maxSessions: 2,
multiCapabilities: [
{
'browserName': 'chrome',
'browser_version': '11.0',
shardTestFiles: false,
maxInstances: 1,
maxSessions: 1,
count: 1,
specs: [ 'test/e2e/VE1-Spec.js', 'test/e2e/VE2-Spec.js' ]
}, {
shardTestFiles: false,
'browserName': 'chrome',
'browser_version': '9.0',
maxInstances: 1,
maxSessions: 1,
count: 1,
specs: ['test/e2e/DG1-Spec.js', 'test/e2e/DG2-Spec.js']
}],
Try the below multiCapabilities configuration. This is working fine for me.
multiCapabilities: [
{
shardTestFiles: true,
maxInstances: 1,
sequential: true,
browserName: 'chrome',
specs: ['specs/spec1.js','specs/spec2.js','specs/spec3.js']
},
{
shardTestFiles: true,
maxInstances: 1,
sequential: true,
browserName: 'chrome',
specs: ['specs/spec4.js',
'specs/spec5.js',
'specs/spec6.js',
]
}
The above congfiguration will launch two chrome instance and executes spec1,spec2 and spec3 on chrome instance 1. And remaining 3 specs will be executed on chrome instance 2.
Thanks Sudharsan. I did not find any documentation for "sequential" property in protractor. Commenting sequential out also made it work.
However when I tried following it worked:
maxSessions: 2,
multiCapabilities: [
{
browserName: 'chrome',
name: 'CAPABILITY_1',
logName: 'LOGNAME1_USERNAME1_A',
shardTestFiles: false,
maxInstances: 1,
maxSessions: 1,
count: 1,
specs: [ 'test/e2e/VE1-Spec.js', 'test/e2e/VE2-Spec.js' ]
}, {
shardTestFiles: false,
'browserName': 'chrome',
name: 'CAPABILITY_2',
logName: 'LOGNAME1_USERNAME2_BB,
maxInstances: 1,
maxSessions: 1,
count: 1,
specs: ['test/e2e/DG1-Spec.js', 'test/e2e/DG2-Spec.js']
}]
This seems to remove any confusion between the 2 capabilities in even the log file as each line has the logname of the particular spec to show which capability is executing it. I just wonder in Sudarshan's case he may have a different version of protractor etc.
Finally you can even print your capability (found from config.ts in github) in your code to ensure its working right.
browser.getProcessedConfig().then(function(config) {
// config.capabilities is the CURRENT capability being run, if
// you are using multiCapabilities.
console.log('Executing capability', config.capabilities);
});