9

Can anyone provide me with a detailed explanation on how to setup nightwatch and start writing browser tests? I have searched for such information online and was unable to find it. The nightwatch.js website had good information about various nightwatch command line commands, but not about actually setting up a nightwatch project, which is what I am having trouble with.

Specifically, I do not have a good understanding of the various files that come with installation of nightwatch, and how I am supposed to use them.

Raj Prabakhar
  • 165
  • 1
  • 3
  • 7
  • http://nightwatchjs.org/guide Is a good guide. You should install night watch using '-g' then you will need to create a nightwatch.json file in the directory that your project is in. Make sure you read any errors that you see in the terminal during the process. – Jeffpowrs Jun 24 '14 at 18:53

5 Answers5

13

Step-by-Step Beginner's Tutorial

We needed an up-to-date, well-researched and maintained tutorial for Nightwatch for our team so we wrote one: https://github.com/dwyl/learn-nightwatch

Codeship Dependency Status devDependency Status contributions welcome

We (highly) recommend using a nightwatch.conf.js (.js) file for configuring Nightwatch because (unlike a .json file) it allows you leave in-line comments to your fellow developers (i.e avoid "WTF" moments by communicating) and to evolve your configuration with variables & functions as needed.

Also, we prefer to install Nightwatch (and its required dependencies) locally so it's clear to everyone exactly what is required to run the project and which versions we are using.

Using the selenium-download module will download the latest versions of Selenium Standalone Server and Chromedriver (both required to run a basic Nightwatch test) for your OS and means you will be up-and-running much faster.

Rather than including the whole tutorial here we invite you to Star/Fork it on GitHub: https://github.com/dwyl/learn-nightwatch#step-by-step-tutorial

Feedback / questions / updates / improvements are always welcome!

nelsonic
  • 25,667
  • 19
  • 83
  • 109
  • 1
    This isn't quite working for me. The problem I'm having is that selenium-download isn't actually grabbing the packages and placing them into the bin directory specified. I'm also a little confused why you're not just calling the nightwatch command from the root directory i.e. `nightwatch --config nightwatch.conf.js` and instead using the following `node_modules/.bin/nightwatch --config nightwatch.conf.js`. It should be accessible from the project root. – Andre Oct 18 '16 at 20:39
  • Hi @Andre, the _reason_ for using `node_modules/.bin/nightwatch` is to make it _clear_ to the team that we are not using a "_global_" version but rather the `nightwatch` that is installed _locally_ for the project. you can use `nightwatch --config nightwatch.conf.js` if you prefer. both work fine. – nelsonic Oct 20 '16 at 10:49
  • Also, with regards to `selenium-download` can you please raise an issue on GitHub so we can help debug: https://github.com/dwyl/learn-nightwatch/issues StackOverflow comments aren't great for detailed trouble-shooting. thanks! – nelsonic Oct 20 '16 at 10:51
  • 1
    I've having the same issue with selenium-download not putting the chromdriver and selenium server into the bin, has this been addressed yet? – Kode_12 Nov 06 '16 at 00:42
  • @Kode_12 yes if you're having issues, please raise on GitHub: https://github.com/dwyl/learn-nightwatch/issues with as much detail as you can so we can help debut. StackOverflow comments are not a _great_ place to troubleshoot. – nelsonic Nov 09 '16 at 19:38
6

You need basiclly two things:

  • The nightwatch.json file in the root of your project
  • And nightwatch installed (npm install -g nightwatch).

After that you use it on the command line as described in the documentation here and it will automatically grab your nightwatch.json file and run your tests based on the default test_setting.

I opened up an issue to add a nightwatch init command, so the setup of the nightwatch.json file is easier.

Further reading

mrzmyr
  • 5,014
  • 4
  • 28
  • 54
0

You can go through this step-by-step method to get better understanding
Nightwatch.js Part 1
Nightwatch.js Part 2

Seun Adekunle
  • 123
  • 1
  • 9
-1

one big problem for users "is not worked on count 1-2-3".

so we find many-many-many times our all internet :)

and.

1) nightwatch is installed (by .rpm, .deb, npm, downloaded). is haven't questions

2) is worked by execution "nightwatch" on CLI

3) but where wunderbar example????????????? of course, on internet!

4) by my bad memory and catalog list in simple test: - create catalog - create in catalog 2 dirs:

  • bin for web-drivers (add chromedriver, selenium-server-standalone as minimum)

  • tests for tests

5) we need this simple config - nightwatch.json in catalog (use any simple which access have)

6) create-copy-paste any simple test in test catalog (it's one on planet :)

7)it's all, run in catalog by CLI: nightwatch

you need only this? for first time, before documentation readings? ;)

nexoma
  • 147
  • 2
  • 9
-3
$ npm install -g yo
$ npm install -g generator-selenium-nightwatch
$ yo selenium-nightwatch
$ npm install
$ npm test
Kavit Shah
  • 375
  • 1
  • 2
  • 11