Opera browser in Selenium grid: Driver class not found - selenium

I'm trying to setup an environment with Selenium grid to execute my Selenium test on a remote machine. The only browser I can`t get to work is Opera. I configured it the same as the other browsers. However when I start the node it shows a Driver class not found.
I`m Running windows 8.1 Enterprise 64 bit on my host computer
The node and the host are on windows 7 Enterprise 32 bit service pack 1
On the host opera is installed, the opera webdriver is in C:/GUI-Tests/Drivers/operadriver.exe, I tried the 32 bit webdriver and the 64 bit webdriver and I`m still getting the error:
13:30:37.169 INFO - Driver class not found: com.opera.core.systems.OperaDriver
13:30:37.169 INFO - Driver provider com.opera.core.systems.OperaDriver registration is skipped: Unable to create new instances on this machine.
13:30:37.178 INFO - Driver class not found: com.opera.core.systems.OperaDriver
13:30:37.178 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
If anyone knows something about this problem please help me.
Extra information about my environment
Starting the hub:
java -jar selenium-server-standalone-3.3.1.jar -role hub -hubConfig hubConfig.json
My Hub config:
{
"host": ip,
"maxSessions": 5,
"port": 4444,
"cleanupCycle": 5000,
"timeout": 300000,
"newSessionWaitTimeout": -1,
"servlets": [],
"prioritizer": null,
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"nodePolling": 180000,
"platform": "WINDOWS"
}
Starting the node:
java -jar selenium-server-standalone-3.3.1.jar -role node -nodeConfig nodeConfig.json
My node config file:
{
"capabilities":
[
{
"browserName": "opera",
"platform": "WINDOWS",
"maxInstances": 5,
"seleniumProtocol": "WebDriver",
"webdriver.opera.driver": "C:/GUI-Tests/Drivers/operadriver.exe"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 1,
"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": {}
}
A screenshot of the drivers location:

Answering my own question because I discovered the answer, and I`m hoping to help everyone that googles on this question :)
Well it turns out opera driver is a legacy driver, you won't need it.
You do need the Opera browser and operachromiumdriver. In c# define your capabilities as:
capabilities = new DesiredCapabilities();
capabilities.SetCapability(CapabilityType.BrowserName, "operablink");
capabilities.Platform = new Platform(PlatformType.Windows);
_webDriver = new RemoteWebDriver(_gridServerUri, capabilities);
On your node:
{
"capabilities":
[
{
"browserName": "operablink",
"platform": "WINDOWS",
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 1,
"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": {}
}
I hope this will be useful to someone at least it was useful to me.
Note:
operachromiumdriver is in my path variable
my node and hub are running Windows 7

Related

Selenium: Session externalKey not available

The Selenium Grid Hub I am running displays this error message whenever a Robot Framework automation test (kicked off by a Jenkins job) requests a Chrome browser from the Hub:
Session [(null externalkey)] not available and is not among the last
1000 terminated sessions.
I've spent hours searching and trying proposed solutions with no luck.
Running a Linux server as a Selenium Grid Hub and a windows server as a Selenium Grid Node. Have tried each node with versions 3.0.1, 3.5.3, 3.13.0, and 3.141.59 of the selenium-server-standalone-<version>.jar files. A third server runs Jenkins.
The Hub appears to be config'd properly because this works fine:
http://10.1.10.231:4444/grid/console
I've also run the jar files at the command line with -debug at the end but no further information is displayed. Have also tried -Dselenium.LOGGER.level=WARNING on the "java side" of the command line with no further information displayed than using -debug.
We have another set of servers with the same config that runs just fine.
Anyone have an idea of what this message is indicating?
Nitty-gritty follows.
Grid Hub:
java -jar -Xms1024m -Xmx2048m selenium-server-standalone-3.141.59.jar -role hub -hubConfig ./hub-config.json
hub-config.json:
{
"port": 4444,
"newSessionWaitTimeout": -1,
"servlets" : [],
"withoutServlets": [],
"custom": {},
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"cleanUpCycle": 5000,
"role": "hub",
"debug": false,
"browserTimeout": 360,
"timeout": 1800
}
Grid Node:
SET CHROMEDRIVER=.\bin\chromedriver_win32-v2.37\chromedriver.exe
SET IEDRIVER=.\bin\IEDriverServer.exe
SET FFDRIVER=.\bin\geckodriver-v0.11.1-win32\geckodriver.exe
START "SeleniumNode" java -Xms1024m -Xmx2048m ^
-Dwebdriver.gecko.driver=%FFDRIVER% ^
-Dwebdriver.ie.driver=%IEDRIVER% ^
-Dwebdriver.chrome.driver=%CHROMEDRIVER% -Dwebdriver.chrome.args="--disable-extensions" ^
-jar .\bin\selenium-server-standalone-3.141.59.jar -role node -nodeConfig .\node-config.json
node-config.json:
{
"capabilities":
[
{
"browserName": "firefox",
"maxInstances": 5,
"platform": "WINDOWS",
"seleniumProtocol": "WebDriver"
},
{
"browserName": "chrome",
"maxInstances": 5,
"platform": "WINDOWS",
"seleniumProtocol": "WebDriver"
},
{
"browserName": "internet explorer",
"maxInstances": 5,
"platform": "WINDOWS",
"seleniumProtocol": "WebDriver"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 5,
"port": 5555,
"register": true,
"registerCycle": 5000,
"hub": "http://10.1.10.231:4444",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {},
"browserTimeout": 0,
"timeout": 1800,
"cleanUpCycle": 2000
}
Figured this one out! Hopefully it will help others who have reported this error message and not received a solution.
As is most often the case with an issue like this, especially when there's a known-working setup right beside the broken instance, it was an (embarrassingly) silly config issue. The Robot tests were pointing to this URL to get a browser:
http://10.1.10.75:4444/wd/hub/static/resource/hub.html
and it should have been pointing to this path:
http://10.1.10.75:4444/wd/hub
At least it was an easy fix.

Can't reach connection to Selenium Server hub from virtual node

So, I have PC with Windows 10 Pro, and virtual Windows 10 Pro installed on the same PC via VMWare workstation, network adapter mode in virtual OS set to "NAT".
I run this command on real OS (hub):
java -jar selenium-server-standalone-3.141.59.jar -role hub
And this command on virtual OS (node):
java -jar selenium-server-standalone-3.141.59.jar -role node -nodeConfig nodeconfig.json
nodeconfig.json contains this:
{
"capabilities":
[
{
"browserName": "chrome",
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 5,
"port": -1,
"register": true,
"registerCycle": 5000,
"hub": "http://192.168.116.1:4444/grid/register/",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {}
}
When I'm trying to connect node to hub, I got this message in console:
Registered a node http://192.168.116.1:4444
Marking the node http://192.168.116.1:4444 as down: cannot reach the node for 2 tries
How can I solve this ? I already tried to set virtual OS network adapter mode to "Bridged", but in this case I can't get connection at all ...
That was a problem with firewall, after turning it off everything seems to work.

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?

PhantomJS WebDriver timeout (access via Selenium Grid)

I need to set (descrease) PhantomJS timeout: 300000 (300sec) -> 30000 (30sec)
I have Selenium Grid with attached PhantomJS as WebDriver.
PhantoimJS exec command:
phantomjs --config=phantomjs.json --webdriver=6661 --webdriver-selenium-grid-hub=http://127.0.0.1:4440
Content of phantomjs.json (i add random values for test):
{
"resourceTimeout": 123456,
"timeout": 345678,
"wait": 234567
}
But in Selenium grid shows timeout: 300000
Screenshot: http://i.stack.imgur.com/hPwBQ.png
I found a solution.
Here is config for selenium grid (hub.json):
{
"host": null,
"port": 4440,
"newSessionWaitTimeout": -1,
"servlets" : [],
"prioritizer": null,
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"nodePolling": 5000,
"cleanUpCycle": 5000,
"timeout": 60000,
"browserTimeout": 60000,
"maxSession": 25,
"maxInstances": 25,
"jettyMaxThreads":-1
}
So i need to rub selenium with params:
java -jar selenium-server-standalone-2.45.0.jar -role hub -hubConfig hub.json
The profit!

Setting up a node on a VM

I have my selenium all configured but seem to be having issues getting it to launch the browser on my windows VM. I think it's because I haven't haven't included the correct path to the driver. Currently it stands as...
java -jar .\selenium-server-standalone-2.39.0.jar -role node -port 1001 -hub http://xxx.xxx.xx.xxx:4444/grid/register
After reading online I assumed it's cause I'm missing the following...
-Dwebdriver.ie.driver="C:\selenium\IEDriverServer.exe"
I've tried various different ways to include this path into the above statement but keep getting 'poorly formatted Java property setting (I expect to see '=') -Dwebdriver: Usage: java -jar selenium-server.jar [-interactive] [options]'
if anyone could show me the correct format I'd really appreciate it.
Thanks.
According to documentation, you can use a system property:
System.setProperty("webdriver.ie.driver", "C:\selenium\IEDriverServer.exe")
Of course this path would have be the correct on the remote machine!
If you use Maven for your builds, then the Selenium binary downloader might interest you.
I would suggest running the node and having the node load a .json config file that looks something like this.
{
"capabilities":
[
{
"browserName": "firefox",
"acceptSslCerts": true,
"javascriptEnabled": true,
"takesScreenshot": false,
"firefox_profile": "",
"browser-version": "31",
"platform": "WINDOWS",
"maxInstances": 5
},
{
"browserName": "chrome",
"maxInstances": 5,
"platform": "WINDOWS"
},
{
"browserName": "internetExplorer",
"maxInstances": 1,
"platform": "WINDOWS"
}
],
"configuration":
{
"_comment" : "This is configuration for the grid node 1.",
"cleanUpCycle": 2000,
"timeout": 30000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"port": 5555,
"host": ip,
"Dwebdriver.chrome.driver=C:\\Selenium\\chromedriver.exe": "",
"Dwebdriver.ie.driver=C:\\Selenium\\IEDriverServer.exe": "",
"register": true,
"hubPort": 4444,
"maxSessions": 5
}
}