Nightwatch : Unable to create new service : ChromeDriverService - node.js

I am trying to automate a simple test case using Nightwatch framework of validating a login. I have followed the steps mentioned on : https://www.softwaretestingmaterial.com/browser-automation-with-nightwatch-and-selenium/
The problem arises when I execute the command node nightwatch tests/bing_test.js in node.js command prompt which results in a error message.
Below is my nightwatch.json configs :
{
"src_folders": ["tests"],
"output_folder": "reports",
"custom_commands_path": "",
"custom_assertions_path": "",
"page_objects_path": "",
"globals_path": "",
"selenium": {
"start_process": true,
"server_path": "./lib/selenium-server-standalone-3.8.1.jar",
"log_path": "./reports",
"host": "127.0.0.1",
"port": 4445,
"cli_args": {
"webdriver.chrome.driver": "./lib/drivers/chromedriver.exe",
"webdriver.gecko.driver": "./lib/drivers/geckodriver.exe",
"webdriver.edge.driver": "./lib/drivers/MicrosoftWebDriver.exe"
}
},
"test_settings": {
"default": {
"launch_url": "http://localhost",
"selenium_port": 4445,
"selenium_host": "localhost",
"silent": true,
"screenshots": {
"enabled": true,
"path": "./reports/screenshots"
},
"desiredCapabilities": {
"browserName": "chrome",
"marionette": true,
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome"
}
},
"firefox": {
"desiredCapabilities": {
"browserName": "firefox"
}
},
"edge": {
"desiredCapabilities": {
"browserName": "MicrosoftEdge"
}
}
}
}
Error Message :
[Bing Test] Test Suite
======================
Response 500 POST /wd/hub/session (363ms)
{ value:
{ error:
[ "Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'",
"System info: host: 'PDC2LAP-7173253', ip: '192.168.43.196', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'",
'Driver info: driver.version: unknown' ],
message: 'Unable to create new service: ChromeDriverService' },
status: 33 }
An error occurred while retrieving a new session: "Unable to create new service: ChromeDriverService"
at endReadableNT (_stream_readable.js:1129:12)
at processTicksAndRejections (internal/process/next_tick.js:76:17)
_________________________________________________
TEST FAILURE: 1 error during execution 0 tests failed, 0 passed. 2.886s
× bing_test
An error occurred while retrieving a new session: "Unable to create new service: ChromeDriverService"
at endReadableNT (_stream_readable.js:1129:12)
at processTicksAndRejections (internal/process/next_tick.js:76:17)
SKIPPED:
- Bing search test
I have tried to debug the issue by going through the comments on GIT forum by setting "webdriver.chrome.driver": "" and "start_process": false, but none of the two worked.
ChromeDriver Version - v72
Selenium Standalone Jar - 3.8.1
Please feel free to guide me to any existing answer/documentation that persists for this issue.

Related

Unable to create session from org.openqa.selenium.remote.NewSessionPayload, with phantomjs and nightwatch.js

I am trying to execute my test over Phantom JS in nightwatchjs
I am using Selenium server with nightwatchjs and cucumber
I took the following link as a reference-
https://github.com/nightwatchjs/nightwatch/wiki/Running-tests-in-PhantomJS
There are other answers as well but none is matching mine. this might be a configuration issue but I am not able to cut it. Can someone please help me out here.
error:
NFO Request: POST /wd/hub/session
- data: {"desiredCapabilities":{"browserName":"phantomjs","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","phantomjs.binary.path":"/usr/local/lib/node_modules/phantomjs/lib/phantom/bin/phantomjs","phantomjs.cli.args":["--ignore-ssl-errors=true"],"silent":false}}
- headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":270}
ERROR Response 500 POST /wd/hub/session (482ms) { value:
{ message: 'Unable to create session from org.openqa.selenium.remote.NewSessionPayload#5c510db\nBuild info: version: \'3.12.0\', revision: \'7c6e0b3\', time: \'2018-05-08T15:15:08.936Z\'\nSystem info: host: \'Chirags-MacBook-Pro.local\', ip: \'fe80:0:0:0:142a:4efe:d208:27ae%en0\', os.name: \'Mac OS X\', os.arch: \'x86_64\', os.version: \'10.13.5\', java.version: \'1.8.0_171\'\nDriver info: driver.version: unknown',
error: 'session not created' },
status: 33 }
{ Error [ERR_UNHANDLED_ERROR]: Unhandled error. ([object Object])
at ClientManager.emit (events.js:171:17)
at Nightwatch.<anonymous> (/Users/prateik/Codebase/NightCuke/node_modules/nightwatch/lib/runner/clientmanager.js:68:10)
at Object.onceWrapper (events.js:273:13)
at Nightwatch.emit (events.js:182:13)
at HttpRequest.<anonymous> (/Users/prateik/Codebase/NightCuke/node_modules/nightwatch/lib/index.js:501:10)
at HttpRequest.emit (events.js:182:13)
at IncomingMessage.<anonymous> (/Users/prateik/Codebase/NightCuke/node_modules/nightwatch/lib/http/request.js:172:16)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1086:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
context:
{ message: 'Connection refused! Is selenium server started?\n',
data: { value: [Object], status: 33 } } }
it says driver.version:unknown, can this be the issue?
all the components are at their latest versions
"cucumber": "^4.0.0",
"nightwatch": "^0.9.21",
"nightwatch-cucumber": "^9.1.2",
"phantomjs-prebuilt": "^2.1.16",
"selenium-server": "^3.12.0"
nightwatch.conf.js
//Nightwatch Configuration
const seleniumServer = require('selenium-server')
const phantomjs = require('phantomjs-prebuilt')
const chromedriver = require('chromedriver')
const geckodriver = require('geckodriver')
require('nightwatch-cucumber')({
cucumberArgs: [
'--require-module', 'babel-core/register',
'--format', 'node_modules/cucumber-pretty',
'--require', 'hooks.js',
'--require', 'features/step_definitions',
'--format-options', '{"colorsEnabled":false}',
'--format', 'json:reports/cucumber.json',
'features'
],
nightwatchOutput: true
})
module.exports = {
// src_folders:'features',
output_folder: 'reports',
custom_assertions_path: '',
page_objects_path: 'page_objects/',
live_output: true,
disable_colors: false,
selenium: {
start_process: true,
server_path: seleniumServer.path,
log_path: '/reports',
host: '127.0.0.1',
port: 4444,
cli_args: {
'webdriver.chrome.driver': chromedriver.path,
'webdriver.gecko.driver' : geckodriver.path,
"webdriver.edge.driver" : "",
}
},
test_settings: {
default: {
launch_url: 'http://localhost',
selenium_port: 4444,
selenium_host: '127.0.0.1',
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
silent:false
//chromeOptions:['start-fullscreen']
},
selenium: {},
screenshots: {
enabled: true,
on_failure: true,
path: 'screenshots'
}
},
phantomjs: {
//launch_url: 'http://localhost/',
selenium_port: 4444,
selenium_host: '127.0.0.1',
desiredCapabilities: {
browserName: 'phantomjs',
javascriptEnabled: true,
acceptSslCerts: true,
//platform: 'Mac OS X',
"phantomjs.binary.path": phantomjs.path,
"phantomjs.cli.args" : ['--ignore-ssl-errors=true']
},
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true
}
}
}
}

" A new session could not be created" error is throwing when the WebdriverIO test is run

I am having one test as selenium.js which is written using WebdriverIO and Node.js. When I run the test, I am getting an error as "driver.version: unknown".
I have validated my System PATH variable and chrome driver version. But couldn't find out the root cause.
selenium.js:
var webdriverio = require('webdriverio');
var options = {
desiredCapabilities: {
browserName: 'chrome'
}
};
webdriverio
.remote(options)
.init()
.url('http://www.google.com')
.getTitle().then(function(title) {
console.log('Title was: ' + title);
})
.end()
.catch(function(err) {
console.log(err);
});
Error:
{ Error: A new session could not be created.
at end() - C:\Projects\Testing_Tool_Evaluation\my-first-react-test\selenium.js:15:6
details: undefined,
message: 'Unable to create new service: ChromeDriverService\nBuild info: version: \'3.13.0\', revision: \'2f0d292\', time: \'2018-06-25T15:32:19.891Z\'\nSystem info: host: \'SUARUMG-IN-LE01\', ip: \'10.0.75.1\', os.name: \'Windows 10\', os.arch: \'amd64\', os.version: \'10.0\', java.version: \'1.8.0_161\'\nDriver info: driver.version: unknown',
type: 'RuntimeError',
seleniumStack:
{ type: 'SessionNotCreatedException',
message: 'A new session could not be created.',
orgStatusMessage: 'Unable to create new service: ChromeDriverService\nBuild info: version: \'3.13.0\', revision: \'2f0d292\', time: \'2018-06-25T15:32:19.891Z\'\nSystem info: host: \'SUARUMG-IN-LE01\', ip: \'10.0.75.1\', os.name: \'Windows 10\', os.arch: \'amd64\', os.version: \'10.0\', java.version: \'1.8.0_161\'\nDriver info: driver.version: unknown' } }
I can observe the below Capabilities in the selenium server after running the test
Capabilities are: {
"browserName": "chrome",
"handlesAlerts": true,
"javascriptEnabled": true,
"locationContextEnabled": true,
"loggingPrefs": {
"browser": "ALL",
"driver": "ALL"
},
"requestOrigins": {
"url": "http:\u002f\u002fwebdriver.io",
"version": "4.13.0",
"name": "webdriverio"
},
"rotatable": true
}

cannot run nightwatch.js tests in chrome browser on linux machine

I am trying to run nightwatch.js in chrome browser on linux machine.
My nightwatch tests run perfectly on windows machine using windows version of chrome driver.
I updated nightwatch.json file and gave path to linux version of chromedriver but my tests do not run and give error
npm run test-e2e --test tests/regression/testcase1.js
************Command Line Argument:*********************
Starting selenium server... started - PID: 12625
[regression / TEST1] Test Suite
Running: Login to UI
Error retrieving a new session from the selenium server
Error writing log file to: /home/abc/testing/AutomationFramework/logs/selenium-debug.log
Connection refused! Is selenium server started?
{ value:
{ message: 'Unable to create new service: ChromeDriverService\nBuild info: version: \'3.12.0\', revision: \'7c6e0b3\', time: \'2018-05-08T15:15:08.936Z\'\nSystem info: host: \'virtualserver01\', ip: \'127.0.1.1\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'4.4.0-124-generic\', java.version: \'1.8.0_171\'\nDriver info: driver.version: unknown',
error: 'session not created' },
status: 33 }
I also have Google chrome installed on my linux machine
$ google-chrome --version
Google Chrome 65.0.3325.181
My nightwatch.json file is as follows
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"globals_path" : "nightwatch.global.js",
"custom_commands_path": "./commands",
"selenium" : {
"start_process" : true,
"server_path" : "./bin/selenium-server-standalone-3.12.0.jar",
"log_path" : "./logs",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "./bin/chromedriver"
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"use_xpath": true,
"selenium_port" : 4444,
"selenium_host" : "localhost",
"screenshots" :{
"enabled" : true,
"path" : "./screenshots",
"on_failure" : true
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"args": ["disable-web-security"],
"prefs": {
}
}
}
}
}
}

Running selenium tests using nightwatch on linux

I have a linux box and I am trying to run selenium tests (written in nightwatch) on it. I installed the chromedriver at
http://chromedriver.storage.googleapis.com/index.html?path=2.9/
(the linuxx64 bit one)
I also installed the standalone selenium jar
I run the following command
DISPLAY=:1 xvfb-run java -jar lib/selenium-server-standalone-2.52.0.jar -Dwebdriver.chrome.driver=lib/chromedriver
Here's my nightwatch configuration:
{
"src_folders": [
"tests"
],
"output_folder": "reports",
"custom_commands_path": "custom_commands",
"custom_assertions_path": "",
"page_objects_path": "",
"live_output" : true,
"globals_path": "globals.js",
"selenium": {
"start_process": true,
"server_path": "lib/selenium-server-standalone-2.52.0.jar",
"log_path": "",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "lib/chromedriver",
"webdriver.chromeJenkins.driver": "../../tools/chromedriver/chromedriver",
"webdriver.ie.driver": "lib/IEDriverServer_x64_2.52.2.exe",
"trustAllSSLCertificates": true
}
},
"test_workers": {
"enabled": true,
"workers": "auto"
},
"test_settings": {
"default": {
"launch_url": "",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"screenshots": {
"enabled": true,
"on_failure": true,
"on_error": true,
"path": "./screenshots"
},
"end_session_on_fail": false,
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"args": [
"use-fake-device-for-media-stream",
"use-fake-ui-for-media-stream"
]
}
}
},
"jenkins" : {
"selenium_port" : 4444,
"selenium_host" : "127.0.0.1",
"cli_args" : {
"webdriver.chrome.driver" : "lib/chromedriver"
},
"chromeOptions" : {
"args" : ["--no-sandbox"]
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"platform" : "LINUX",
"chromeOptions" : {
"args" : ["--no-sandbox"]
}
}
}
}
Then I run the following command
DISPLAY=:1 xvfb-run --server-args="-screen 0, 1366x768x24" ./nightwatch -e jenkins --test tests/blog.js
The tests start to run, but when I look at the output the driver gets stuck at a particular element. It tries to find the element but times out. When I run the tests on my local machine, I do not get this error.
Am I doing something wrong here?
Check your browser viewport size. It's probably smaller in xvfb than it is on your main screen, and the site your testing may change behavior at different resolutions. Saw that my first day.
TL;DR
My chrome window was the same size, but opening the debugging pane changed site behavior.

tedious.js set requestTimeout = 0 but still got timed out

I have this config file:
{
"userName": "user",
"password": "pass",
"server": "shrd-cw",
"options": {
"encrypt": true,
"requestTimeout": 0
}
}
However, I still received requestTimeout error:
{ [RequestError: Timeout: Request failed to complete in 15000ms]
name: 'RequestError',
message: 'Timeout: Request failed to complete in 15000ms',
code: 'ETIMEOUT' }

Resources