Driver class not found: com.opera.core.systems.OperaDriver - selenium-grid

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
}
}

Related

How do you setup an HtmlUnit node with Selenium Grid?

I'm having trouble setting up an HtmlUnit node with Selenium Grid.
I'm launching my Hub with:
java -jar selenium-server-standalone.jar -role hub -port 4444
And HtmlUnitDriver nodes with:
java -jar selenium-server-standalone.jar -role node -browser browserName=htmlunit,maxInstances=5 -hub http://localhost:4444/grid/register -port 5564
My code to connect to the node, which is getting the exception, looks something like:
DesiredCapabilities cap = new DesiredCapabilities();
cap.setBrowserName("htmlunit");
cap.setJavascriptEnabled(false);
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), cap);
The exception I'm getting is:
Unable to create session from {
"desiredCapabilities": {
"browserName": "htmlunit",
"server:CONFIG_UUID": "93a0486d-c9f6-46da-8065-603ab07c0294",
"javascriptEnabled": false
},
"capabilities": {
"firstMatch": [
{
"browserName": "htmlunit",
"server:CONFIG_UUID": "93a0486d-c9f6-46da-8065-603ab07c0294"
}
]
}
}
To set up a Selenium Grid instance, I use the Selenium Foundation library. The "standalone" JAR brings in scads of transitive dependencies you don't need that end up creating conflicts. I created a sample project (local-grid-utility) that launches a Selenium 2 Grid that dispenses PhantomJS sessions, which could be easily altered to launch a Selenium 3 Grid dispensing HtmlUnit sessions.
The key to getting HtmlUnit sessions stood up in Grid is providing a complete class path that includes all of the dependencies. Here's what the library assembles for HtmlUnitDriver 2.40.0:
${JAVA_HOME}/jre/bin/java -cp ${M2_ROOT}/repository/org/seleniumhq/selenium/selenium-support/3.141.59/selenium-support-3.141.59.jar:${M2_ROOT}/repository/org/seleniumhq/selenium/htmlunit-driver/2.40.0/htmlunit-driver-2.40.0.jar:${M2_ROOT}/repository/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.jar:${M2_ROOT}/repository/xerces/xercesImpl/2.12.0/xercesImpl-2.12.0.jar:${M2_ROOT}/repository/org/seleniumhq/selenium/selenium-api/3.141.59/selenium-api-3.141.59.jar:${M2_ROOT}/repository/net/sourceforge/htmlunit/htmlunit-core-js/2.40.0/htmlunit-core-js-2.40.0.jar:${M2_ROOT}/repository/org/eclipse/jetty/websocket/websocket-api/9.4.28.v20200408/websocket-api-9.4.28.v20200408.jar:${M2_ROOT}/repository/xalan/xalan/2.7.2/xalan-2.7.2.jar:${M2_ROOT}/repository/org/eclipse/jetty/jetty-xml/9.4.28.v20200408/jetty-xml-9.4.28.v20200408.jar:${M2_ROOT}/repository/org/apache/httpcomponents/httpclient/4.5.12/httpclient-4.5.12.jar:${M2_ROOT}/repository/org/eclipse/jetty/jetty-http/9.4.28.v20200408/jetty-http-9.4.28.v20200408.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/com.beust.jcommander_1.72.0.jar:${M2_ROOT}/repository/org/apache/httpcomponents/httpcore/4.4.13/httpcore-4.4.13.jar:${M2_ROOT}/repository/xml-apis/xml-apis/1.4.01/xml-apis-1.4.01.jar:${M2_ROOT}/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar:${M2_ROOT}/repository/net/sourceforge/htmlunit/neko-htmlunit/2.40.0/neko-htmlunit-2.40.0.jar:${M2_ROOT}/repository/com/squareup/okhttp3/okhttp/3.11.0/okhttp-3.11.0.jar:${M2_ROOT}/repository/commons-net/commons-net/3.6/commons-net-3.6.jar:${M2_ROOT}/repository/org/seleniumhq/selenium/selenium-server/3.141.59/selenium-server-3.141.59.jar:${M2_ROOT}/repository/xalan/serializer/2.7.2/serializer-2.7.2.jar:${M2_ROOT}/repository/org/eclipse/jetty/jetty-client/9.4.28.v20200408/jetty-client-9.4.28.v20200408.jar:${M2_ROOT}/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:${M2_ROOT}/repository/org/apache/commons/commons-text/1.8/commons-text-1.8.jar:${M2_ROOT}/repository/org/eclipse/jetty/jetty-io/9.4.28.v20200408/jetty-io-9.4.28.v20200408.jar:${M2_ROOT}/repository/net/sourceforge/htmlunit/htmlunit-cssparser/1.5.0/htmlunit-cssparser-1.5.0.jar:${M2_ROOT}/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar:${M2_ROOT}/repository/org/apache/httpcomponents/httpmime/4.5.12/httpmime-4.5.12.jar:${M2_ROOT}/repository/org/seleniumhq/selenium/jetty-repacked/9.4.12.v20180830/jetty-repacked-9.4.12.v20180830.jar:${M2_ROOT}/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar:${M2_ROOT}/repository/org/eclipse/jetty/websocket/websocket-client/9.4.28.v20200408/websocket-client-9.4.28.v20200408.jar:${M2_ROOT}/repository/org/brotli/dec/0.1.2/dec-0.1.2.jar:${M2_ROOT}/repository/com/google/guava/guava/28.1-jre/guava-28.1-jre.jar:${M2_ROOT}/repository/com/squareup/okio/okio/1.14.0/okio-1.14.0.jar:${M2_ROOT}/repository/net/sourceforge/htmlunit/htmlunit/2.40.0/htmlunit-2.40.0.jar:${M2_ROOT}/repository/org/seleniumhq/selenium/selenium-remote-driver/3.141.59/selenium-remote-driver-3.141.59.jar:${M2_ROOT}/repository/commons-io/commons-io/2.6/commons-io-2.6.jar:${M2_ROOT}/repository/org/eclipse/jetty/jetty-util/9.4.28.v20200408/jetty-util-9.4.28.v20200408.jar:${M2_ROOT}/repository/org/eclipse/jetty/websocket/websocket-common/9.4.28.v20200408/websocket-common-9.4.28.v20200408.jar org.openqa.grid.selenium.GridLauncherV3 -role node -servlets org.openqa.grid.web.servlet.LifecycleServlet -host 192.168.1.6 -port 34464 -nodeConfig /Users/bb8d/github/Selenium-Foundation/target-s3/classes/nodeConfig-s3-9CF40153.json
You could create your own standalone package to bundle up the dependencies if that suits your fancy. The node server is provided by the GridLauncherV3 class. I also add the LifecycleServlet plugin to enable remote shutdown. The host specification corresponds to the local machine, and the port is auto-selected from whatever is currently available.
The JSON configuration file looks like this:
{
"capabilities": [
{
"browserName": "htmlunit",
"javascriptEnabled": true,
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
}
],
"custom": {
},
"debug": false,
"downPollingLimit": 2,
"enablePlatformVerification": true,
"host": "0.0.0.0",
"hub": "http:\u002f\u002f192.168.1.6:4445\u002fwd\u002fhub",
"maxSession": 5,
"nodePolling": 5000,
"nodeStatusCheckTimeout": 5000,
"port": -1,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"register": true,
"registerCycle": 5000,
"role": "node",
"servlets": [
],
"unregisterIfStillDownAfter": 60000,
"withoutServlets": [
]
}
The critical settings can be specified in the command line, but I think the config file is more manageable.

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

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!

Selenium grid - node configuration file for Firefox not reading moz:firefoxOptions

I have setup my selenium grid (currently 1 hub and 1 node).
The hub is working fine but for my node I setup the below configuration file (nodeconfig.json)
I wanted to start the firefox in headless mode but it looks like the "moz:firefoxOptions" configuration did not catch up.
I tried setting the "moz:firefoxOptions" in a variety of location in side the json file without any luck :( .
I are using :
windows server 2016 64bit ,
selenium-server-standalone 3.9.1
geckodriver v0.19.1
firefox v59.0
we are running the node using the following command :
java -Dwebdriver.gecko.driver="geckodriver.exe" -Dwebdriver.chrome.driver="chromedriver.exe" -jar selenium-server-standalone-3.9.1.jar -role node -nodeConfig nodeconfig.json
I can tell that the configuration file was read as I can see it in the selenium grid console.
nodeconfig.json file:
{
"capabilities": [
{
"browserName": "firefox",
"maxInstances": 5,
"seleniumProtocol": "WebDriver",
"alwaysMatch": {
"moz:firefoxOptions": {
"args": [
"-headless"
]
}
}
},
{
"browserName": "chrome",
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
}
],
"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": {}
}
In addition from the logs I can tell that the argument is not added.
The relevant line is :
1520854660258 mozrunner::runner INFO Running command: "C:\Program Files\Mozilla Firefox\firefox.exe" "-marionette" "-profile" "C:\Users\avi\AppData\Local\Temp\rust_mozprofile.03tQm3hduVDR"
As per the documentation the argument is --headless not -headless. So possibly you have to change to :
"moz:firefoxOptions": {
"args": [
"--headless"
]
}
You can find a detailed discussion in How to make firefox headless programatically in Selenium with python?

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.

Can nightwatch.js use usingServer from selenium-webdriver?

I have a suite of tests using local drivers built with nightwatch. Works well.
I am running a basic test using Perfecto Mobile and selenium-webdriver. It works with this example.(https://community.perfectomobile.com/series/20208/posts/1002862)
I am trying to connect my suite of nightwatch test to perfecto, but can't start selenium. If this is the url of the selenium server.
var url = "https://mobilecloud.perfectomobile.com/nexperience/perfectomobile/wd/hub";
I tried a few ways to set it up under nightwatch config, but can't make it work.
"selenium" : {
"start_process" : true,
"host" : "mobilecloud.perfectomobile.com/nexperience/perfectomobile/wd/hub"
}
Is there an equivalent to usingServer in nightwatch? I haven't seen anything in the docs.
driver = new webdriver.Builder().
usingServer(url).
withCapabilities(capabilities).
build();
Turns out this was the setup needed.
"test_settings" : {
"perfecto" : {
"use_ssl": true,
"default_path_prefix": "/nexperience/perfectomobile/wd/hub",
"selenium_port" : 443,
"selenium_host" : "mobilecloud.perfectomobile.com",
"desiredCapabilities": {
"browserName": "xxx",
"deviceName": "xxx",
"user": "xxx#xxx.xxx",
"password": "xxx",
"platformName": "xxx"
}
}
}
The important part that didn't work at the time of writing the question: the default_path_prefix was not customizable.
/wd/hub was the default prefix. But I really needed /nexperience/perfectomobile/wd/hub.
Two days later, this commit was introduced. It is available in 0.9.5 release.
https://github.com/nightwatchjs/nightwatch/commit/aa24c2c2334c42388318498f654d8fe2957967d1