Open sharadJay opened 9 years ago
Hi @sharadJay .
Hmm... In my environment, it did not reproduce the problem..
Could you try the following examples? https://github.com/tatsuyafw/gulp-nightwatch/tree/master/examples.
I want to know the result of withCliArgs:array
task.
Nope I did not find any success. Following is my gulpfile
var gulp = require('gulp');
var rimraf = require('rimraf');
nightwatch = require('gulp-nightwatch');
gulp.task('cleanReports', function (cb) {
rimraf('./reports', cb);
});
gulp.task('SampleTest',function(){
gulp.src('')
.pipe(nightwatch({
configFile: 'nightwatch.json',
cliArgs: [ '--env US', '--tag sample' ]
}));
})
and I have environment setup like this in my nightwatch config:-
"default" : {
"launch_url" : "http://www.google.com",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : "/screenshots"
},
"end_session_on_fail":true,
"desiredCapabilities": {
"browserName": "phantomjs",
"javascriptEnabled": true,
"acceptSslCerts": true,
"phantomjs.binary.path" : "node_modules/resources/phantomjs/bin/phantomjs",
"phantomjs.cli.args": "--webdriver=5558 --webdriver-selenium-grid-hub=http://localhost:4444"
}
},
"US" : {
"launch_url" : "http://www.google.com",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : true,
"path" : "/screenshots"
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
I was hoping test with tag sample starts on chrome as on US environment but tests are started on default i.e. phantomjs
Um, I've run gulp task using your nightwatch.json, gulpfile.js. and the test worked fine. Of course on Chrome.
gulpfile.js
var gulp = require('gulp');
var nightwatch = require('gulp-nightwatch');
gulp.task('SampleTest',function(){
gulp.src('')
.pipe(nightwatch({
configFile: 'nightwatch.json',
cliArgs: [ '--env US', '--tag sample' ]
}));
});
tests/google.com.js
module.exports = {
tags: [ 'sample' ],
'Demo google test': function(browser) {
browser
.url('https://google.com')
.assert.title('Google')
.end();
}
};
nightwatch.json
{
"src_folders" : [ "tests" ],
"output_folder" : "reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"globals_path" : "",
"selenium" : {
"start_process" : false,
"server_path" : "",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "",
"webdriver.ie.driver" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://www.google.com",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : "/screenshots"
},
"end_session_on_fail":true,
"desiredCapabilities": {
"browserName": "phantomjs",
"javascriptEnabled": true,
"acceptSslCerts": true,
"phantomjs.binary.path" : "node_modules/resources/phantomjs/bin/phantomjs",
"phantomjs.cli.args": "--webdriver=5558 --webdriver-selenium-grid-hub=http://localhost:4444"
}
},
"US" : {
"launch_url" : "http://www.google.com",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : true,
"path" : "/screenshots"
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
And, command line outputs.
$ gulp SampleTest
[22:02:19] Using gulpfile ~/tmp/sandbox/gulpfile.js
[22:02:19] Starting 'SampleTest'...
[22:02:19] Finished 'SampleTest' after 5.95 ms
[22:02:19] log file
[22:02:19] Starting nightwatch...
[Google Com] Test Suite
=======================
Running: Demo google test
✔ Testing if the page title equals "Google".
OK. 1 assertions passed. (2.795s)
$
What version of gulp-nightwach are you using? I need a little more information.
I am using 0.2.2 version for gulp-nightwatch.
I see that environment used is default if tag is provided in cli arguments section. I have tried running same combination using nightwatch and it runs perfectly fine.