Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment is ignored if tags and environment both are used #22

Open
sharadJay opened this issue Aug 23, 2015 · 4 comments
Open

Environment is ignored if tags and environment both are used #22

sharadJay opened this issue Aug 23, 2015 · 4 comments

Comments

@sharadJay
Copy link

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.

@tatsuyafw
Copy link
Owner

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.

@sharadJay
Copy link
Author

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

@tatsuyafw
Copy link
Owner

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.

@sharadJay
Copy link
Author

I am using 0.2.2 version for gulp-nightwatch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants