1

I have search for about 8 hours and read pretty much every related topic on this matter but i didn't found a solution so far. The closest i found is https://github.com/nightwatchjs/nightwatch/issues/1368 however that matter was resolved with updating selenium standalone server and i use all the latest versions.

Am in the need of starting the firefox browser with a specific profile which i already configured and named "nightwatch" My system pref: win 10 64bit java version "1.8.0_121" npm -version 3.10.10 geckodriver-v0.18.0-win64 Selenium standalone 3.5.0 Firefox developer edition 56.0b5 (64-bit)

My nightwatch.json file is:

 {
  "src_folders" : ["nw/tests"],
  "output_folder" : "nw/reports",
  "globals_path" : "nightwatch.globals.js",
  "test_workers": {
    "enabled": true,
    "workers": "auto"
  },
  "selenium" : {
    "start_process" : true,
    "server_path" : "./node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.5.0.jar",
    "log_path" : "nw/logs",
    "host" : "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "./node_modules/chromedriver/lib/chromedriver/chromedriver.exe",
      "webdriver.ie.driver" : "",
      "webdriver.gecko.driver": "geckoDriver/geckodriver.exe"
    }
  },
  "test_settings" : {
    "default" : {
      "launch_url" : "http://google.com",
      "selenium_port"  : 4444,
      "selenium_host"  : "localhost",
      "silent": true,
      "screenshots" : {
        "enabled" : true,
        "path" : ""
      },
      "desiredCapabilities": {
        "browserName": "firefox",
        "javascriptEnabled": true,
        "acceptSslCerts": true,
    "marionette": false
      }
    }

  }
}

I have tried adding

"webdriver.firefox.profile": "nightwatch"

in both the selenium and test settings. The browser is started with the needed profile but the url from my test (example: some URL) is never entered thus my test always fails.

If i put "marionette":true as described in the issue above Firefox is not started with the desired "nightwatch" profile and additionally my test is always failing at the 1st line .waitForElementVisible("body", 1000)

I have been search and reading a lot on the issue and didn't found something that will help me. I understood that the gecko driver has the possibility on receiving arguments in which the firefox profile can be specified, however my knowledge is very limited on the subject (4 days into nightwatch) and i simply can't resolve it at this moment. I even tried modifying the selenium.js file within .\nightwatch\lib\runner

with the following:

this.cliOpts = [
    '-Dwebdriver.firefox.profile=nightwatch', //i added this line in the file .\node_modules\nightwatch\lib\runner\selenium.js
    '-jar', this.settings.selenium.server_path,
    '-port', this.port
  ];

The same issue happens, Firefox browser is opened with the desired profile but the test is just not executing and it fails completely after 30sec of wait with the log saying "java.lang.NullPointerException"

Added content to reflect the comments below When i put the following code

"cli_args" : {
      "webdriver.ie.driver" : "",
      "webdriver.gecko.driver": "geckoDriver/geckodriver.exe",
      "webdriver.firefox.profile": "nightwatch"

    }

Firefox is started with the desired profile but the test is not executing (not entering even the test URL (as mentioned above). As the log is too long to be included in the original post it is available on google drive https://drive.google.com/open?id=0Bz4bu5Fo5Vq_NEhEZFlnSDBjWm8

  • Have you tried this http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/firefox/index.html – smit9234 Aug 23 '17 at 18:34
  • Can you paste the whole error log ? – Ray Aug 24 '17 at 02:34
  • @Raymond As the log is too long to be included i attached a google drive Url for it – zaDaMozedaNeznam Aug 24 '17 at 07:38
  • @smit9234 Thanks for following up with the url, i was also reading about adding code for custom profile, there was a person that tried modifying the default language of the browser and his code was included in the actual test, however it was unsuccessful for him (also for me). I mention this because i don't know where to include that code, pardon my ignorance on the subject. – zaDaMozedaNeznam Aug 24 '17 at 07:42
  • 1
    After many options, i have downgraded to Selenium 3.4.0 and with marionette:true i was able to find a working solution. – zaDaMozedaNeznam Aug 26 '17 at 20:49

1 Answers1

1

Updated with my whole config, change the settings and location if you needed.

module.exports = {
  "src_folders": [
    "scripts/test"// Where you are storing your Nightwatch e2e tests
  ],
  "output_folder": "./reports", // reports (test outcome) output by nightwatch
  "selenium": { // downloaded by selenium-download module (see readme)
    "start_process": true, // tells nightwatch to start/stop the selenium process
    "server_path": "./node_modules/nightwatch/bin/selenium.jar", // the standard alone selenium server jar
    "host": "127.0.0.1",
    "port": 4444, // standard selenium port
    "cli_args": { // chromedriver is downloaded by selenium-download (see readme)

      "webdriver.chrome.driver" : "C:/chrome-win32/chromedriver.exe",
       "webdriver.gecko.driver" : "geckodriver.exe", //firefox driver location 
       "webdriver.ie.driver"    : "IEDriverServer.exe"
    }
  },
  "test_settings": {
    "default": {
      "screenshots": {
        "enabled": false, // if you want to keep screenshots
        "path": "" // save screenshots here
      },
      "globals": {
        "waitForConditionTimeout": 5000 // sometimes internet is slow so wait.
      },
      "desiredCapabilities": { // use Chrome as the default browser for tests
        "browserName": "chrome",
      },
    },
    "chrome": {
      "desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled": true, // turn off to test progressive enhancement
        "chromeOptions" :{
//        "args": [
//               'headless',
//                // Use --disable-gpu to avoid an error from a missing Mesa
//                // library, as per
//                // https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
//                'disable-gpu',
//            ],
        "binary": 'C:/chrome-win32/chrome.exe'
        },
        "selenium": {
            "cli_args": {
              "webdriver.chrome.driver" : "C:/chrome-win32/chromedriver.exe",
            },
        },
      },
    },
    "firefox":{
     "desiredCapabilities": {
        "browserName": 'firefox',
        "javascriptEnabled": true,
        "marionette": false,
        "acceptSslCerts": true,
        "acceptInsecureCerts" :true        
      },
        "selenium": {
                "cli_args": {
                    "webdriver.gecko.driver" : "geckodriver.exe" ,
                    //"webdriver.firefox.bin" : 'C:/tools/firefox_v39/firefox.exe'
                },
        },      
    },
    "ie" :{
        "desiredCapabilities": {
        "browserName": 'internet explorer',
        "javascriptEnabled": true,
        "acceptSslCerts": true
      },  
    }
  }
}
Ray
  • 1,539
  • 1
  • 14
  • 27
  • I tried this, the only difference is that i never have placed "acceptInsecureCerts" :true so far. However as soon as i initialize marionette:true, dispite the fact that it is also included "webdriver.firefox.profile": "nightwatch" the firefox browser launches with a dynamic (un-profiled interface) and additionally my test always fails at the body tag (as mentioned above) Can you please include the whole nightwatch.json maybe am missing something else – zaDaMozedaNeznam Aug 24 '17 at 07:45
  • included the config now – Ray Aug 24 '17 at 08:29
  • i tried to make your file into a valid json and used it as a nightwatch.json file. However it never starts the firefox browser with the desired created profile "nightwatch" even when i add the necessary code to do it. Moreover with your json i get only to the point that the URL is inserted and always fails at the body tag. Maybe this would have been helpfull however it is outdated (version wise) also it is not available https://github.com/nightwatchjs/nightwatch/wiki/Firefox-related-settings There has to be a simple way to pass arguments such as those for chromeOptions, one would think – zaDaMozedaNeznam Aug 24 '17 at 12:30
  • check this : https://github.com/mozilla/geckodriver#firefox-capabilities – Ray Aug 25 '17 at 01:54
  • And also update the selenium standalone and firefox to the latest version – Ray Aug 25 '17 at 02:36
  • Hi i did found that url 2 days ago and (its in my bookmarks) i thought with those args i can tell the gecko driver to launch firefox with the desired profile, however i couldn't manage to find a way how to configure that. Am using all the latest versions of gecko selenium nightwatch firefox ... – zaDaMozedaNeznam Aug 25 '17 at 07:45
  • Yesterday i also was researching how to make such configuration but with no luck. My understanding of the issue is that it should be in the nightwatch.json file but i did so many tryouts with no success that my dopamine levels are in negative – zaDaMozedaNeznam Aug 25 '17 at 07:48