tacoss / grunt-nightwatch

Run your Nightwatch.js tests with Grunt
50 stars 22 forks source link

It doesnt work #32

Closed Sly777 closed 9 years ago

Sly777 commented 9 years ago

Hi,

Today, i added it to my gruntfile but it always give error. I cannot find why give this error.

'Starting selenium server... started - PID: 11340 Fatal error: Cannot read property '1' of null'.

Nightwatch.json

{
  "standalone": true,
  "jar_url": "http://selenium-release.storage.googleapis.com/2.44/selenium-server-standalone-2.44.0.jar",

  "test_settings" : {
    "default" : {
      "desiredCapabilities": {
        "browserName": "firefox",
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    },

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

gruntfile setting

nightwatch: {
    options: {
        config_path: '<%= staticWebFolder %>/nightwatchSettings.json',
        src_folders: '<%= staticWebFolder %>/scripts/e2eTests'
    }
}

grunt version: 0.4.5 grunt-cli version: 0.1.13

nightwatch & grunt-nightwatch: last version

pateketrueke commented 9 years ago

Could you run grunt nightwatch --verbose and paste the output here?

Sly777 commented 9 years ago

Hi @pateketrueke, result is below.

Running tasks: e2eTest

Running "e2eTest" task

Running "nightwatch" task Reading ../../StaticWeb/nightwatchSettings.json...OK Parsing ../../StaticWeb/nightwatchSettings.json...OK

Custom JSON-file: ../../StaticWeb/nightwatchSettings.json Task options {"standalone":true,"jar_path":null,"jar_url":"http://selenium-release.storage.go ogleapis.com/2.44/selenium-server-standalone-2.44.0.jar","jar_version":"2.44.0", "config_path":"../../StaticWeb/nightwatchSettings.json"} Using already downloaded Selenium from C:\grunt-nightwatch\selenium-server-standalone-2.44.0.jar Starting selenium server... started - PID: 5284 Fatal error: Cannot read property '1' of null

Execution Time (2015-03-02 07:42:24 UTC) loading tasks 10ms █ 1% nightwatch 1.5s ███████████████████████████████████████████████ 99% Total 1.5s

pateketrueke commented 9 years ago

Have you tried Nightwatch standalone for running your tests before?

Sly777 commented 9 years ago

@pateketrueke yeah. It works standalone but not with grunt. i tried the sample of grunt-nightwatch also it doesn't work too.

jcarpe commented 9 years ago

@pateketrueke This is closed, but has it made it into the master (and subsequently the NPM module)? Using NPM on my project, and if the above actually fixes this issue, it'd be great if it were included in all distributions.

Thanks!

EDIT: I see the fix in the source from NPM, but I am getting the same error as described above... I'll continue looking, but may add a new issue.

cactusme commented 9 years ago

I ran into this issue with 0.4.6, if I have config_path in options

pateketrueke commented 9 years ago

Can you paste your output using the --verbose please?

cactusme commented 9 years ago

Running tasks: nightwatch

Running "nightwatch" task Reading c:\Users\mxx\main\client/nightwatch.json...OK Parsing c:\Users\mxx\main\client/nightwatch.json...OK Reading ./nightwatch.json...OK Parsing ./nightwatch.json...OK

Custom JSON-file: ./nightwatch.json Task options {"standalone":false,"jar_path":null,"jar_url":"http://selenium-release.storage.g oogleapis.com/{x}.{y}/selenium-server-standalone-{x}.{y}.{z}.jar","jar_version": "2.45.0","config_path":"./nightwatch.json"} Settings for default {"src_folders":["src\test\selenium\spec"],"output_folder":"test_reports\sele nium","test_settings":{"default":{"silent":true,"output":true,"launch_url":"http ://localhost:3002/","selenium_port":4444,"selenium_host":"localhost","screenshot s":{"enabled":false,"path":"."},"desiredCapabilities":{"browserName":"firefox"," javascriptEnabled":true,"acceptSslCerts":false}},"chrome":{"desiredCapabilities" :{"browserName":"chrome","javascriptEnabled":true,"acceptSslCerts":false}}},"cus tom_commands_path":".","custom_assertions_path":".","page_objects_path":".","glo bals_path":".","selenium":{"start_process":true,"server_path":"selenium-server-s tandalone-2.45.0.jar","log_path":".","host":"localhost","port":4444,"cli_args":{ "webdriver.chrome.driver":".","webdriver.ie.driver":"."}}} Fatal error: Cannot read property '1' of null

cactusme commented 9 years ago

Gruntfile configuration

    nightwatch: {
        options: {
            config_path: './nightwatch.json'
        },
        hub: {
            config_path: './nightwatch-hub.json'
        }
    }
cactusme commented 9 years ago

No error if I comment out config_path. It picks up the default nightwatch.json

    nightwatch: {
        options: {
            //config_path: './nightwatch.json'
        },
        hub: {
            config_path: './nightwatch-hub.json'
        }
    }
pateketrueke commented 9 years ago

Actually grunt-nightwatch will always pick up the nightwatch.json file in the current working directory.

Try to rename your file and try with config_path again.

cactusme commented 9 years ago

Same error after changing to use nightwatch-hub.json

Running tasks: nightwatch

Running "nightwatch" task Reading c:\Users\hyau\mcs\mcs_platform-ui\main\client/nightwatch.json...OK Parsing c:\Users\hyau\mcs\mcs_platform-ui\main\client/nightwatch.json...OK Reading ./nightwatch-hub.json...OK Parsing ./nightwatch-hub.json...OK

Custom JSON-file: ./nightwatch-hub.json Task options {"standalone":false,"jar_path":null,"jar_url":"http://selenium-release.storage.g oogleapis.com/{x}.{y}/selenium-server-standalone-{x}.{y}.{z}.jar","jar_version": "2.45.0","config_path":"./nightwatch-hub.json"} Settings for default {"src_folders":["src\test\selenium\spec"],"output_folder":"test_reports\sele nium","test_settings":{"default":{"silent":true,"output":true,"launch_url":"http ://localhost:3002/","selenium_port":4444,"selenium_host":"abc.xxx.c om","screenshots":{"enabled":false,"path":"."},"desiredCapabilities":{"browserNa me":"firefox","javascriptEnabled":true,"acceptSslCerts":false}},"chrome":{"desir edCapabilities":{"browserName":"chrome","javascriptEnabled":true,"acceptSslCerts ":false}}},"custom_commands_path":".","custom_assertions_path":".","page_objects _path":".","globals_path":".","selenium":{"start_process":false,"server_path":"s elenium-server-standalone-2.45.0.jar","log_path":".","host":"localhost","port":4 444,"cli_args":{"webdriver.chrome.driver":".","webdriver.ie.driver":"."}}} Fatal error: Cannot read property '1' of null

cactusme commented 9 years ago

Fine without grunt

$ nightwatch -c ./nightwatch-hub.json

[Simple Test] Test Suite

Running: Demo test Google ✔ Element was visible after 448 milliseconds. ✔ Element <button[name=btnG]> was visible after 215 milliseconds. ✔ Testing if element <#main> contains text: "Night Watch".

OK. 3 assertions passed. (1m 36s / 96887ms)

pateketrueke commented 9 years ago

I'm not sure, but you can try this?

config_path: path.resolve('./nightwatch-hub.json')

If that works then the grunt task isn't resolving the config_path before apply other path-related fixes.

cactusme commented 9 years ago

(Please note I am on Windows)

Running tasks: nightwatch

Running "nightwatch" task Reading c:\Users\mxx\main\client/nightwatch.json...OK Parsing c:\Users\mxx\main\client/nightwatch.json...OK Reading c:\Users\mxx\main\client\nightwatch-hub.json...OK Parsing c:\Users\mxx\main\client\nightwatch-hub.json...OK

Custom JSON-file: c:\Users\mxx\main\client\nightwatch-hub.json Task options {"standalone":false,"jar_path":null,"jar_url":"http://selenium-release.storage.g oogleapis.com/{x}.{y}/selenium-server-standalone-{x}.{y}.{z}.jar","jar_version": "2.45.0","config_path":"c:\Users\mxx\main\client\nig htwatch-hub.json"} Settings for default {"src_folders":["src\test\selenium\spec"],"output_folder":"test_reports\sele nium","test_settings":{"default":{"silent":true,"output":true,"launch_url":"http ://localhost:3002/","selenium_port":4444,"selenium_host":"abc.xxx.c om","screenshots":{"enabled":false,"path":"."},"desiredCapabilities":{"browserNa me":"firefox","javascriptEnabled":true,"acceptSslCerts":false}},"chrome":{"desir edCapabilities":{"browserName":"chrome","javascriptEnabled":true,"acceptSslCerts ":false}}},"custom_commands_path":".","custom_assertions_path":".","page_objects _path":".","globals_path":".","selenium":{"start_process":false,"server_path":"s elenium-server-standalone-2.45.0.jar","log_path":".","host":"localhost","port":4 444,"cli_args":{"webdriver.chrome.driver":".","webdriver.ie.driver":"."}}} Fatal error: Cannot read property '1' of null

vchouhan commented 9 years ago

I'm having the same issue when I try to setup grunt-nightwatch to use the nightwatch.json file. screen shot 2015-04-23 at 14 34 57 screen shot 2015-04-23 at 11 25 13 screen shot 2015-04-23 at 14 34 23

I get the following error

module.js:338 throw err; ^ Fatal error: Cannot read property '1' of null

vchouhan commented 9 years ago

@Sly777, I fixed my issue. it's nothing to do with grunt-nightwatch. Just want to check with you if you have a nightwatch installed as part of your dependency or dev-dependency, or it's just installed globally?

_I wanted to shrinkwrap my packages and when I executed that command I got a warning message stating missing a dependency night watch for grunt-nightwatch. I had night watch installed globally but for some reason grunt-nightwatch is looking for nightwatch inside node_modules, after installing the package and removing the configpath from my options the grunt nightwach task executed without any errors screen shot 2015-04-23 at 16 08 42

screen shot 2015-04-23 at 16 10 48

Check if this solution works for you.

ryan-schroeder commented 9 years ago

Still noticing this. "Fatal error: Cannot read property '1' of null" when I specify the config. Default is fine, just fyi =) Thanks for writing this!

domasx2 commented 9 years ago

@ryan-schroeder @vchouhan Cannot read property '1' of null was fixed with https://github.com/gextech/grunt-nightwatch/commit/2ce088193d3a6f56b23f28d07120be5aa77a4d27, it was an error while printing an error :)

DiegoTonini commented 7 years ago

Really the bug was fixed? I have this issue.

pateketrueke commented 7 years ago

@DiegoTonini are you testing the latest versions?

Please share the code you're using.