NightwatchJS - unable to create session when Selenium Server is run manually - selenium

I have run in this strange problem that I can reproduce on 2 out of 3 machines... Nightwatch can not connect to Selenium Server if it is run manually. If I let Nightwatch handle Selenium Server there is no issue.
I have tried multiple Selenium and Chromedriver (required browser but issue reproduces with all other browsers) versions. Works on one machine, fails on other two.
This is my Nightwatch.json file:
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",
"selenium" : {
"start_process" : false,
"start_session" : true,
"server_path" : "./selenium-server-standalone-3.14.0.jar",
"log_path" : "",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "./chromedriver_2.41.exe"
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities": {
"browserName": "chrome"
}
}
}
}
I am running Selenium server with:
java -jar selenium-server-standalone-3.14.0.jar -debug
I am running the test with:
nightwatch -t demo_test_google.js
Results I get after running the test:
Selenium Server:
21:48:15.693 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.14.0', revision: 'aacccce0'
21:48:15.694 INFO [GridLauncherV3$1.launch] - Launching a standalone Selenium Server on port 4444
2018-09-12 21:48:15.792:INFO::main: Logging initialized #371ms to org.seleniumhq.jetty9.util.log.StdErrLog
21:48:16.145 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
21:48:21.340 DEBUG [WebDriverServlet.handle] - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession#774638b9
21:48:21.345 DEBUG [WebDriverServlet.lambda$handle$3] - /session: Executing POST on /session (handler: BeginSession)
21:48:21.469 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"acceptSslCerts": true,
"browserName": "chrome",
"javascriptEnabled": true,
"name": "Demo Test Google"
}
21:48:21.471 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
NightwatchJS test:
Running: Demo test Google
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ value:
{ message: 'Unable to create new service: ChromeDriverService\nBuild info: version: \'3.14.0\', revision: \'aacccce0\', time: \'2018-08-02T20:13:22.693Z\'\nSystem info: host: \'xxxxxxxxxxxx\', ip: \'xxx.xxx.xxx.xxx\', os.name: \'Windows 10\', os.arch: \'amd64\', os.version: \'10.0\', java.version: \'1.8.0_181\'\nDriver info: driver.version: unknown',
error: 'session not created' },
status: 33 }
Any help would be appreciated!
Thanks in advance!

Related

Selenium Grid Driver.Version Unknown

I know that this question is asked many times and the answers helped me once.
I used to start as an experiment a Selenium Grid Hub on my local machine and an Node on an other machine. Both were started using parameters on the command line. I was able to start a test so the configuration worked.
Since I do not want to run the hub on my local machine I started is on the same machine as the node but now using JSON config files.
Now I get the WebDriverException: Error forwarding the new session cannot find ... giving the driver.version: unknown error.
I am sure that I pass the version so the error leaves me puzzled.
The node is according to the hub's out put correctly registered. The nodeconfig JSON is:
{
"capabilities":
[
{
"browserName": "chrome",
"maxInstances": 5,
"seleniumProtocol": "WebDriver",
"version": 93,
"platform": "WIN10"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 5,
"port": 5555,
"register": true,
"registerCycle": 5000,
"hub": "http://localhost:4444",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {}
}
The console output in Eclipse shows this error description:
Caused by: org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless, --window-size=1920,955, --ignore-certificate-errors, --disable-gpu], extensions: []}, platform: WIN10, version: 93}
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'XXXXXXXXXX', ip: 'ipx.xxx.xxx.xxx', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_302'
Driver info: driver.version: unknown
The hub show following:
ipy.yyy.yyy.yyy INFO [RequestHandler.process] - Got a request to create a new session: Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless, --window-size=1920,955, --ignore-certificate-errors, --disable-gpu], extensions: []}, platform: WIN10, version: 93}
ipy.yyy.yyy.yyy INFO [RequestHandler.process] - Error forwarding the new session cannot find : Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless, --window-size=1920,955, --ignore-certificate-errors, --disable-gpu], extensions: []}, platform: WIN10, version: 93}
org.openqa.grid.common.exception.CapabilityNotPresentOnTheGridException: cannot find : Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless, --window-size=1920,955, --ignore-certificate-errors, --disable-gpu], extensions: []}, platform: WIN10, version: 93}
The Chrome version on the node is 93.0.4577.82. Do I need to spell this out?
Can anyone give me a clue how to solve this?
All examples on the net are showing version numbers like 93.0 or 93 .
So yes, I had to spell it out like 93.0.4577.82

'Connection refused! Is selenium server started?\n' while running Nightwatch.js tests against Selenium Grid

I use Nightwatch-Cucumber based on Nightwatch.js to automate my tests. And now I want to use Selenium Grid with a Selenium hub and several Selenium nodes to execute my tests.
These are my current dependencies I actually use:
"devDependencies": {
"chromedriver": "2.37.0",
"cucumber": "3.0.2",
"geckodriver": "1.11.0",
"nightwatch": "0.9.19",
"nightwatch-cucumber": "9.0.0",
"selenium-server-standalone-jar": "3.9.1",
},
And this is my nightwatch.conf.js:
const config = {
globals_path: "globals.js",
output_folder: "reports",
custom_commands_path: "commands",
// custom_assertions_path: 'assertions',
live_output: false,
page_objects_path: "pageobjects",
disable_colors: false,
selenium: {
start_process: true,
server_path: seleniumServer.path,
host: "127.0.0.1",
port: 4444
},
test_settings: {
default: {
launch_url: "http://mywebsite.com"
},
firefox_grid: {
selenium_host: "127.0.0.1",
selenium_port: 4444,
desiredCapabilities: {
browserName: "firefox"
}
selenium: {
start_process: false
}
}
}
};
module.exports = config;
So, and these are the steps I executed to realize everything:
1. Start the Selenium Hub on localhost
java -jar selenium-server-standalone-3.9.1.jar -port 4444 -role hub
2. Start the Selenium Node on localhost
java -jar selenium-server-standalone-3.9.1.jar -port 5555 -role node
3. Start the Nightwatch tests
./node_modules/.bin/nightwatch --env firefox_grid --tag=myCucumberTag
Current result:
I get an error while executing the Nightwatch tests and I don't know why. It looks like this:
{ Error: Unhandled "error" event. ([object Object])
at ClientManager.emit (events.js:185:19)
at Nightwatch.<anonymous> (/Users/GRme/projects/Aservo/DP/lcm2/testautomation/end2end-web-tests/node_modules/nightwatch/lib/runner/clientmanager.js:68:10)
at Object.onceWrapper (events.js:316:30)
at emitOne (events.js:115:13)
at Nightwatch.emit (events.js:210:7)
at HttpRequest.<anonymous> (/Users/GRme/projects/Aservo/DP/lcm2/testautomation/end2end-web-tests/node_modules/nightwatch/lib/index.js:501:10)
at emitThree (events.js:135:13)
at HttpRequest.emit (events.js:216:7)
at IncomingMessage.<anonymous> (/Users/GRme/projects/Aservo/DP/lcm2/testautomation/end2end-web-tests/node_modules/nightwatch/lib/http/request.js:172:16)
at emitNone (events.js:110:20)
at IncomingMessage.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1057:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
context:
{ message: 'Connection refused! Is selenium server started?\n',
data: { value: [Object], status: 33 } } }
The request to the Selenium hub seems to be successful from Nightwatch:
21:50:52.393 INFO - Got a request to create a new session: Capabilities {acceptSslCerts: true, browserName: chrome, javascriptEnabled: true}
21:50:52.399 INFO - Trying to create a new session on test slot {seleniumProtocol=WebDriver, se:CONFIG_UUID=037e48a7-b5bc-44f2-a25b-e85c752095a7, browserName=chrome, maxInstances=5, platformName=MAC, platform=MAC}
And the request also was navigated to the Selenium node:
2018-05-03 21:50:52.418:INFO:osjshC.ROOT:qtp1300393335-22: org.openqa.selenium.remote.server.WebDriverServlet-49d904ec: Initialising WebDriverServlet
21:50:52.450 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession#31a65f95
21:50:52.454 INFO - /session: Executing POST on /session (handler: BeginSession)
21:50:52.546 INFO - Capabilities are: Capabilities {acceptSslCerts: true, browserName: chrome, javascriptEnabled: true}
21:50:52.548 INFO - Capabilities {acceptSslCerts: true, browserName: chrome, javascriptEnabled: true} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
So, what I'm doing wrong and how can I fix it? Is it maybe a problem with the Nightwatch.js and/or Selenium Server Standalone Version?
This error message...
message: 'Connection refused!
...implies that the Selenium Grid Node was unable to initiate/spawn a new WebClient i.e. Web Browsing session.
Your main issue is in the command being used to start / initialize Selenium Grid Node. The Selenium Grid Node should be started with the desired WebDriver variant as an argument as follows :
Start the Selenium Grid Hub (default on port 4444):
java -jar selenium-server-standalone-3.9.1.jar -role hub
Start the Selenium Grid Node (default on port 5555):
java -Dwebdriver.chrome.driver=C:/path/to/chromedriver.exe -jar selenium-server-standalone-3.9.1.jar -role node -hub http://localhost:4444/grid/register
You can find a similar detailed discussion in Connection refused! Is selenium server started nightwatch on edge

CodeceptJS not accepting proxy settings

I want to pass CodeceptJS requests through an external proxy. I followed the instructions in the docs.
In the logging I see indications the proxy is being passed on, but its not being used by selenium-standalone to proxy requests.
10:56:25.020 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession#7d95346a
10:56:25.020 INFO - /session: Executing POST on /session (handler: BeginSession)
10:56:25.024 INFO - Capabilities are: Capabilities {browserName: chrome, handlesAlerts: true, javascriptEnabled: true, locationContextEnabled: true, loggingPrefs: org.openqa.selenium.logging..., proxy: {httpProxy: http://<myproxy>..., proxyType: manual, socksPassword: <my password>..., socksUsername: <my username>}, requestOrigins: {name: webdriverio, url: http://webdriver.io, version: 4.10.2}, rotatable: true}
10:56:25.024 INFO - Capabilities {browserName: chrome, handlesAlerts: true, javascriptEnabled: true, locationContextEnabled: true, loggingPrefs: org.openqa.selenium.logging..., proxy: {httpProxy: http://<myproxy>..., proxyType: manual, socksPassword: <my password>..., socksUsername: <my username>}, requestOrigins: {name: webdriverio, url: http://webdriver.io, version: 4.10.2}, rotatable: true} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
CodeceptJS version: 1.1.5
NodeJS Version: 8.0
Operating System: mac
Protractor || WebDriverIO || Nightmare version (if related)
selenium-server-standalone-3.9.1
Configuration file:
"helpers": {
"WebDriverIO": {
"url": "https://caworkcompcoverage.com",
"browser": "chrome",
"desiredCapabilities": {
"proxy": {
"proxyType": "manual",
"httpProxy": "http://proxy:8010",
"socksUsername": "my username",
"socksPassword": "my password"
}
}
}
},

Nightwatch/selenium - Error: Unable to access jarfile

I'm trying to run some functional tests but i got this error.
Starting selenium server... There was an error while starting the Selenium server:
Error: Unable to access jarfile
./node_modules/selenium-standalone/.selenium/selenium-server/3.0.1-server.jar
This's my configuration in my nightwatch.json file
"selenium": {
"start_process": true,
"start_session" : true,
"host": "127.0.0.1",
"port": 4444,
"log_path": "./test/e2e/",
"server_path": "./node_modules/selenium-standalone/.selenium/selenium-server/3.0.1-server.jar",
"cli_args" : {
"webdriver.chrome.driver" : "./node_modules/selenium-standalone/.selenium/chromedriver/2.27-x64-chromedriver"
}
}
Check your server_path. Is the file in that location or in some other? Is that the actual Selenium jar & version? Adjust as necessary.

Driver class not found: com.opera.core.systems.OperaDriver

Getting below exception when trying to assign the node to Selenium Grid. And this node is not showing in Grid console. Any idea why am I getting this exception?
java -jar selenium-server-standalone-2.48.2.jar -port 5555 -role node -hub http://localhost:4444/grid/register
:10:41.671 INFO - Launching a Selenium Grid node
:10:43.169 INFO - OS: Windows 7 6.1 amd64
:10:43.174 INFO - v2.48.0, with Core v2.48.0. Built from revision 41bccdd
:10:43.232 INFO - Driver class not found: com.opera.core.systems.OperaDriver
:10:43.232 INFO - Driver provider com.opera.core.systems.OperaDriver is not r
stered
:10:43.262 INFO - Selenium Grid node is up and ready to register to the hub
:10:43.285 INFO - Starting auto registration thread. Will try to register eve
5000 ms.
:10:43.285 INFO - Registering the node to the hub: http://localhost:4444/grid
gister
:10:43.296 INFO - The node is registered to the hub and ready to use
:10:53.760 INFO - The node is registered to the hub and ready to use
For one thing, I would choose Safari over Opera. Secondly, make sure that Selenium Safari and Opera drivers show up amongst your dependencies. You can explicitly define it like so :
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-safari-driver</artifactId>
<version>2.48.2</version>
</dependency>
But, what you basically need to do is configure the Grid node like so, with adjustments for the Mac. This is my hacked-up guess at the configuration. You'll need to adjust it.:
{
"capabilities" : [{
"browserName" : "firefox",
"acceptSslCerts" : true,
"javascriptEnabled" : true,
"takesScreenshot" : false,
"firefox_profile" : "",
"browser-version" : "42",
"platform" : "MAC",
"maxInstances" : 5,
"firefox_binary" : "",
"cleanSession" : true
}, {
"browserName" : "chrome",
"maxInstances" : 5,
"platform" : "MAC",
"webdriver.chrome.driver" : "/Applications/Opera.app/Contents/MacOS/Chrome/chrome"
}, {
"browserName" : "safari",
"maxInstances" : 1,
"platform" : "MAC",
"version" : "12",
"webdriver.safari.driver" : "
https://code.google.com/p/selenium/wiki/OperaDriver
http://selenium-release.storage.googleapis.com/2.48/SafariDriver.safariextz"
}, {
"browserName" : "opera",
"maxInstances" : 1,
"platform" : "MAC",
"version" : "8",
"webdriver.opera.driver" : "???"
}
],
"configuration" : {
"_comment" : "Configuration for Node",
"cleanUpCycle" : 2000,
"timeout" : 30000,
"proxy" : "org.openqa.grid.selenium.proxy.WebDriverRemoteProxy",
"port" : 5555,
"host" : ip,
"register" : true,
"hubPort" : 4444,
"maxSessions" : 5
}
}