I am new to angularjs ,trying to test my app with karma,jasmine and protractor.
here is my conf.js:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'chrome'
},
specs: ['spec.js'],
jasmineNodeOpts: {
showColors: true,
}
};
here is my spec.js
describe('Protractor Demo App', function() {
it('should have a title', function() {
browser.get('http://localhost/First-angular-App/source/');
expect(browser.getTitle()).toEqual('Firstangular app');
});
});
after running protractor conf.js I get this:
but can't run my test how can i do this??
As noted above:
The error message tells exactly why your tests are not running. This option specifies a path to your specs: ['spec.js']. Modify conf.js and set a path to a folder with your specs relative to conf.js: specs: ['tests/spec.js'] or even better specs: ['tests/**/*.js'] (will take all files in tests/ directory as test files).
Upgrading my node version to LTS(Node Website), I fixed this problem.
Related
I am new to JS and Protractor for testing functionalities. I need to include some conditions or loops inside 'Configuration' file of protractor.
Such as, if I need to check my specs running on 'Windows / Mac' platform and a variable provides these details.
I am expecting something like :
exports.config = {
seleniumAddress : 'http://localhost:4444/wd/hub',
getPageTimeout : 30000,
allScriptsTimeout : 30000,
specs : [ ],
framework : 'jasmine2',
***don't know the syntax, am expecting below line and condition need to work for protractor***
***var platform = 'Windows',
if(platform ==='Windows'){***
multiCapabilities: [{
'browserName': 'chrome',
'specs': ['spec1.js']
},
***else {***
'browserName': 'chrome',
'specs': ['spec2.js']
}],
};
Is it possible to validate in Configuration file?
You need to use the getMultiCapabilities function:
getMultiCapabilities: function() {
// TODO: check platform and return list of capability objects
},
I have tried this in my config file*
var reporter = new HtmlScreenshotReporter({
dest: 'target/screenshots',
filename: 'my-report.html'
});
exports.config = {
directConnect: true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
// Framework to use. Jasmine is recommended.
framework: 'jasmine',
// Spec patterns are relative to the current working directory when
// protractor is called.
specs: ['Enter-description-in-resources-spec.js'],
// Options to be passed to Jasmine.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 1100000
}
onPrepare: function() {
jasmine.getEnv().addReporter(new HtmlReporter({
baseDirectory: '/tmp/screenshots'
}));
}
};
but I got a error and I'm unable to understand it
throw new exitCodes_1.ConfigError(logger, 'failed loading configuration file ' + filename);
You are missing a comma after JasmineNodeOpts, please correct and pass your reporter in onPrepare function:
var reporter = new HtmlScreenshotReporter({
dest: 'target/screenshots',
filename: 'my-report.html'
});
exports.config = {
directConnect: true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
// Framework to use. Jasmine is recommended.
framework: 'jasmine',
// Spec patterns are relative to the current working directory when
// protractor is called.
specs: ['Enter-description-in-resources-spec.js'],
// Options to be passed to Jasmine.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 1100000
},
onPrepare: function() {
jasmine.getEnv().addReporter(reporter); // Pass the reporter here which you have defined earlier.
}
};
I have a protractor config file as follows and i use phantomjs to run the tests. It works when i use seleniumServerJar but fails when i use seleniumAddress (pointing to a hub) with a 'The driver executable does not exist' message! Is there any specific config to run phantomjs with selenium-hub?
exports.config = {
//Fails when i use this
//seleniumAddress:"http://selenium-hub.com:4659/wd/hub",
//Works when i use this selenium-standalone jar
seleniumServerJar: '../../../node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar',
framework: 'cucumber',
specs: [
'features/*.feature'
],
capabilities: {
"browserName": "phantomjs",
"phantomjs.binary.path": require("phantomjs").path,
"phantomjs.ghostdriver.cli.args": ["--loglevel=DEBUG"]
},
baseUrl: '',
rootElement: 'body',
resultJsonOutputFile: 'src/test/report.json',
cucumberOpts: {
require: 'features/steps/*_steps.js',
}
};
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
}
};
I setup some tests in protractor for my angular app and i wanted to run a nightly batch and see next day some reports of the tests passed or failed .. . I tried without success protractor-html-screenshot-reporter so now i want to see how to save a log . Is this save a log file?
How i could see second day the result of the tests runner ?
My current protractor conf file :
exports.config = {
seleniumAddress: 'http://imptest2:80/wd/hub',
specs: [
'../E2E/**/*.spec.js'
],
multiCapabilities: [
{
'browserName' : 'chrome',
'ensureCleanSession': 'false',
'shardTestFiles': 'true',
maxInstances:8
}
],
params: {
global: {
url: 'http://impiis/TestsServices/Client',
concern: '01'
}
},
baseUrl: 'http://impiis/TestsServices/Client',
allScriptsTimeout: 500000
};
Thank you
With this simple protractor config file, you should have protractor-html-screenshot-reporter working
var HtmlReporter = require('protractor-html-screenshot-reporter');
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['Exova.LIMS.UI.Testing/e2e/pages/**/*_spec.js'],
baseUrl: 'http://localhost:51494',
onPrepare: function() {
// Add a screenshot reporter and store screenshots to `/tmp/screnshots`:
jasmine.getEnv().addReporter(new HtmlReporter({
baseDirectory: 'tmp/screnshots'
}));
}
};
It was a reporter bug it was solved : https://github.com/jintoppy/protractor-html-screenshot-reporter/pull/38