Unable to run a test in chrome browser.

2,064 views
Skip to first unread message

testingzeal

unread,
Feb 4, 2016, 12:48:18 PM2/4/16
to NightwatchJs
I have just started node.js and wrote a simple script and was able to execute it in firefox and trying to run it in chrome browser.

Unable to run a test using chrome browser. Highlighted are sections that has chrome config and test execution commands.

Please let me know how to resolve it.

=====================================================

Here is my nightwatch.json . I have added chrome driver and highlighted the section. 

{
  "src_folders" : ["tests"],
  "output_folder" : "reports",
  "custom_commands_path" : "commands",
  "custom_assertions_path" : "",
  "page_objects_path" : [
     ],
  "test_workers" : {
    "enabled": false,
    "workers": 3
  },
  "globals_path" : "",

  "selenium" : {
    "start_process" : false,
    "log_path" : "",
    "host" : "docker",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "C:\Chromedriver\chromedriver.exe",
      "webdriver.ie.driver" : ""
    }
  },

  "test_settings" : {
    "default" : {
      "launch_url" : "docker",
      "selenium_port"  : 4444,
      "selenium_host"  : "docker",
      "silent": true,
      "screenshots" : {
        "enabled" : true,
        "path" : "screenshots"
      },
      "desiredCapabilities": {
        "browserName": "firefox",
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    },

    "chrome" : {
      "desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled": true,
        "acceptSslCerts": true,
       }
    }
  }
}


i am executing test using this command 

C:\root\src\test\selenium\nightwatch>node ./nightwatch -t tests\myTestOn
e.js -e chrome --verbose

=================================================
ERROR SyntaxError: C:\root\src\test\selenium\nightwatch\nightwatch.json:
 Unexpected token
    at Object.parse (native)
    at Object.Module._extensions..json (module.js:430:27)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.CliRunner.readSettings (C:\apps\sm\root\src\test\selenium\nightwat
ch\node_modules\nightwatch\lib\runner\cli\clirunner.js:89:23)
    at Object.CliRunner.setup (C:\apps\sm\root\src\test\selenium\nightwatch\node
_modules\nightwatch\lib\runner\cli\clirunner.js:49:8)
    at Object.exports.runner (C:\apps\sm\root\src\test\selenium\nightwatch\node_
modules\nightwatch\lib\index.js:541:17)
    at C:\apps\sm\root\src\test\selenium\nightwatch\node_modules\nightwatch\bin\
runner.js:9:16
ERROR There was an error while starting the test runner:


Error: No testing environment specified.
    at Object.CliRunner.parseTestSettings (C:\apps\sm\root\src\test\selenium\nig
htwatch\node_modules\nightwatch\lib\runner\cli\clirunner.js:441:13)
    at Object.CliRunner.setup (C:\apps\sm\root\src\test\selenium\nightwatch\node
_modules\nightwatch\lib\runner\cli\clirunner.js:51:8)
    at Object.exports.runner (C:\apps\sm\root\src\test\selenium\nightwatch\node_
modules\nightwatch\lib\index.js:541:17)
    at C:\apps\sm\root\src\test\selenium\nightwatch\node_modules\nightwatch\bin\
runner.js:9:16
    at Object.exports.cli (C:\apps\sm\root\src\test\selenium\nightwatch\node_mod
ules\nightwatch\lib\index.js:535:5)
    at Object.<anonymous> (C:\apps\sm\root\src\test\selenium\nightwatch\node_mod
ules\nightwatch\bin\runner.js:8:14)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)

Daniel Rinehart

unread,
Feb 4, 2016, 2:28:00 PM2/4/16
to NightwatchJs
Your JSON file isn't valid. I'd recommend pasting it into http://jsonlint.com/ and make sure it validates there.

--
You received this message because you are subscribed to the Google Groups "NightwatchJs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nightwatchjs...@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/948fd141-32db-4cc3-9c58-668c6f5e1fb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

testingzeal

unread,
Feb 5, 2016, 3:33:56 PM2/5/16
to NightwatchJs
Thank you , I resolved json error .

Here is the error i see now , I have chrome driver pointed in nightwatch.json.



==============



Error retrieving a new session from the selenium server
{ state: 'unhandled error',
  sessionId: null,
  hCode: 453788715,
  value:
   { class: 'java.lang.IllegalStateException',
     message: 'The path to the driver executable must be set by the webdriver.ch
rome.driver system property; for more information, see https://github.com/Seleni
umHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http:
     suppressed: [ [length]: 0 ],
     localizedMessage: 'The path to the driver executable must be set by the web
driver.chrome.driver system property; for more information, see https://github.c
om/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded f
     hCode: 744179755,
     screen: null,
     cause: null },
  class: 'org.openqa.selenium.remote.Response',
  status: 13 }


Connection refused! Is selenium server started?

====Updated nightwatch.json

Janardhan Reddy

unread,
Feb 11, 2016, 8:39:50 AM2/11/16
to NightwatchJs
Hey,  Update "start_process" : false, in nightwatch.json file to "start_process" : true, and see if you are resolved the issue.

Corrinna Rainwater

unread,
Feb 13, 2016, 12:08:43 AM2/13/16
to NightwatchJs
This is the error:   "start_process" : false, 

it needs to be    "start_process" : true,

konanki gangaraju

unread,
Apr 1, 2016, 6:33:00 AM4/1/16
to NightwatchJs
I am unable run programs in chrome ....please ..help me.
This is my nightwatch js...

=========================================================================================
{
  "src_folders": ["./examples/tests"],
"output_folder": "./examples/reports",
"custom_commands_path": "./examples/custom-commands",
"custom_assertions_path": "",
"globals_path": "",
"live_output": false,
"parallel_process_delay": 10,
"disable_colors": false,
"test_workers": false,
  "selenium" : {
    "start_process" : true,
    "server_path" : "./bin/selenium.jar",
    "log_path" : "",
    "cli_args" : {
      "webdriver.chrome.driver" : "bin/chromedriver"
    }
  },

  "test_settings" : {
    "default" : {
      "launch_url" : "https://simplewebrtc.com/demo.html",
      "silent" : true,
      "screenshots" : {
        "enabled" : false,
        "path" : "./screenshots"
      }
    },

    "chrome" : {
      "desiredCapabilities" : {
        "browserName" : "chrome",
        "chromeOptions" : {
          "args" : [
            "use-fake-device-for-media-stream", 
            "use-fake-ui-for-media-stream"
          ]
        }
      }
    }
  }
}
===========================================================================================================
I got error like this
---------------------------------------------------------------------------------------------------------

Error retrieving a new session from the selenium server
{ state: 'unhandled error',
  sessionId: null,
  hCode: 1599180059,
  value:
   { suppressed: [ [length]: 0 ],
     message: 'The driver executable does not exist: C:\\dev\\nightwatch\\node_modules\\nightwatch\\bin\\chromedriver',
     cause: null,
     class: 'java.lang.IllegalStateException',
     hCode: 887165495,
     screen: null,
     localizedMessage: 'The driver executable does not exist: C:\\dev\\nightwatch\\node_modules\\nightwatch\\bin\\chromedriver' },
  class: 'org.openqa.selenium.remote.Response',
  status: 13 }


Connection refused! Is selenium server started?
-----------------------------------


Daniel Rinehart

unread,
Apr 1, 2016, 8:38:09 AM4/1/16
to NightwatchJs
If you examine the output of the error the root cause is a missing driver executable:


message: 'The driver executable does not exist: C:\\dev\\nightwatch\\node_modules\\nightwatch\\bin\\chromedriver',

You need to download the drivers separately and let nightwatch know where the driver is located through the configuration.

More details can be found in the cli_args section at: http://nightwatchjs.org/guide#selenium-settings

--
You received this message because you are subscribed to the Google Groups "NightwatchJs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nightwatchjs...@googlegroups.com.
To post to this group, send email to nightw...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages