user1799835
user1799835

Reputation: 121

Problems with running test with --config

I'm currently trying to run a nightwatch test by passing in the conf.js file via the --config tag. The conf.js file is in the directory below where the nightwatch command will be run from. Looks like this

.
└── project root
    ├── tests
    ├── bin
        └── selenium.jar
        └── chromedriver
    └── other
        └── nightwatch.conf.js
        ├── custom-assertions

Relative part of the conf.js file looks like this

    "src_folders" : [
      "../tests"
    ],
    "custom_commands_path" : "custom-commands",
    "selenium": {
      "start_process": true,
      "server_path": "../bin/selenium.jar",
      "host": "127.0.0.1",
      "port": 4444,
      "cli_args": {
        "webdriver.chrome.driver" : "../bin/chromedriver"
      }
    },

The problem i'm having is if I try to run the test from project root with

nightwatch --config other/nightwatch.conf.js --verbose

I get the following error

Starting selenium server... There was an error while starting the 
Selenium server:

Error: Unable to access jarfile ../bin/selenium.jar

However, if I run it from the other folder and don't specify the --config (because i'm running it from the folder where the conf lives) it works fine. So i'm thinking i'm doing something wrong but I don't know what. Anyone any ideas?

Other info -

  1. The directory set up has to be the way outlined above
  2. The tests have to be ran from the project root
  3. The project root is in /home dir (I don't think it's a permissions issues but it could be I guess)
  4. Nightwatch is installed globally

Let me know if I can provide any other info. Thanks Ally

edit changed 'run project from root' to 'run project from project root'

Upvotes: 0

Views: 415

Answers (1)

sonhu
sonhu

Reputation: 961

You need to adjust your config code to run based on the directory of the package.json or gulpfile.js. Try adjusting your code to the following

    "src_folders" : [
     "tests"
    ],
    "custom_commands_path" : "custom-commands",
    "selenium": {
      "start_process": true,
    "server_path": "bin/selenium.jar",
    "host": "127.0.0.1",
    "port": 4444,
    "cli_args": {
      "webdriver.chrome.driver" : "bin/chromedriver"
    }
},

Upvotes: 1

Related Questions