Modifying an existing nightwatch.json configuration to expand usage

307 views
Skip to first unread message

Matthew Kidd

unread,
Mar 24, 2017, 5:44:01 PM3/24/17
to NightwatchJs
I've recently taken over the test suite for a company that already got nightwatch "working". I'm trying to get to the point that the following 3 commands will all work without conflict:

docker-compose run --rm site1 -e localchrome -t ./tests/basic_search.js
nightwatch
-e chrome -t ./tests/basic_search.js
nightwatch
-t ./tests/basic_search.js

My thought process is as follows:

The docker command is what is current and works but it is completely headless unless the browser window is opening inside the docker container. The two nightwatch calls I would like to run locally by opening the browser, either specified by the environment flag or the default, so I can actually watch the execution locally with the hopes that would facilitate debugging in the browser.

I would like all this to work off just a single nightwatch.json file but I'm open to suggestions.

nightwatch.json:

{
"src_folders" : ["./tests"],
"output_folder" : "./reports",
"page_objects_path" : "./pages",
"custom_assertions_path": "./assertions",
"globals_path" : "",
"live_output" : false,
"parallel_process_delay" : 10,
"disable_colors": false,
"test_workers" : false,

"test_settings" : {
"default" : {
"launch_url" : "https://www.site1.com",
"selenium_host" : "ondemand.saucelabs.com",
"selenium_port" : 80,
"username" : "${USERNAME}",
"access_key" : "${ACCESS_KEY}",
"silent" : true,
"disable_colors": false,
"screenshots" : {
"enabled" : true,
"path" : ""
},
"desiredCapabilities" : {
"browserName" : "chrome",
"platform" : "Windows 10",
"version" : "53.0",
"deviceName" : "",
"javascriptEnabled" : true,
"acceptSslCerts" : true,
"avoidProxy" : true,
"screenResolution" : "1280x1024"
}
},

"chrome" : {
"use_ssl" : false,
"silent" : true,
"output" : true,
"screenshots" : {
"enabled" : true,
"on_failure" : true,
"path" : "screens/chrome"
},
"desiredCapabilities": {
"name" : "",
"browserName": "",
"platform": ""
},
"selenium" : {
"start_process" : false
}
},

"localchrome" : {
"screenshots": {
"enabled": true,
"on_failure": true,
"path": "screens/chrome"
},
"selenium_host" : "chromedriver",
"selenium_port" : 4444
}


}
}

docker-compose.yml:

version: '2'
services:
  chromedriver:
    image: selenium/standalone-chrome
    volumes:
      - /dev/shm:/dev/shm
  site1:
    build:
        context: ./
    depends_on:
      - chromedriver
    environment:
      - WAIT_FOR_HOSTS=chromedriver:4444
    volumes:
      - ./projects/site1:/home/node
  site2:
    build:
        context: ./
    depends_on:
      - chromedriver
    environment:
      - WAIT_FOR_HOSTS=chromedriver:4444
    volumes:
      - ./projects/site2:/home/node
  site3:
    build:
        context: ./
    depends_on:
      - chromedriver
    environment:
      - WAIT_FOR_HOSTS=chromedriver:4444
    volumes:
      - ./projects/site3:/home/node




If either file is confusing, as I attempted to obfuscate the websites, usernames, logins that are hard coded (I plan on moving some to a .env), I'm happy to provide clarification but it is accurate. I've spent a few days googling already but while I'm all the better for having done that I'm still confused. Any help is appreciated to help me understand this configuration.

Matthew Kidd

unread,
Mar 27, 2017, 6:06:39 PM3/27/17
to NightwatchJs
I've made progress. 

I've got the first and third commands "working" without conflict. I think I accomplished this by moving the settings for selenium_host, selenium_port, username, and access_key from default to the localchrome environment.

I'm still working on this but I believe I'm at a point where both test runs are hitting the site under test through a selenium instance be it local on my machine or what appears to be saucelabs.

Thanks for now.

Eric Mumford

unread,
Mar 27, 2017, 7:37:57 PM3/27/17
to NightwatchJs
Your desired capabilities for 'chrome' will fill in from 'default' if you don't specify them. You may be getting incompatible combinations of capabilities for 'chrome' if you are not re-specifying each capability.

Matthew Kidd

unread,
Mar 28, 2017, 1:18:35 PM3/28/17
to NightwatchJs
Yes I discovered this while editing the configuration. For example, chrome is defined as the default browser. I'm working towards a more modular and building upon itself set up.

bharat joshi

unread,
Mar 29, 2017, 3:33:24 AM3/29/17
to NightwatchJs
Hi ,

I need your help regarding the setup of docker for nightwatch , I am trying to run the tests with the same command as you have mentioned

I am getting an exception as "No such file or directory" for the scripts I want to execute

Can you please help me out with the same

Matthew Kidd

unread,
Mar 31, 2017, 11:07:36 AM3/31/17
to NightwatchJs
Turns out, after looking a little deeper into what I took over, the simplest thing to do was start fresh with a new nightwatch.js and get that working and then iterate.

Eric Mumford

unread,
Mar 31, 2017, 12:05:52 PM3/31/17
to nightw...@googlegroups.com
What's your command, and what is your file structure.

Check to make sure you are running nightwatch from the right directory.

--
You received this message because you are subscribed to a topic in the Google Groups "NightwatchJs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nightwatchjs/HzgELssKGkQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nightwatchjs+unsubscribe@googlegroups.com.
To post to this group, send email to nightw...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nightwatchjs/f9360a51-42b2-4cf5-9ada-7e888de6b5e1%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages