WebDriver grid configuration throws error - selenium

I have the following setup:
I am running a grid hub on my local pc with the following config:
java -jar selenium-server-standalone-2.42.0.jar -role hub -grid1Yml grid_configuration.yml
the config looks like this:
hub:
port: 4444
remoteControlPollingIntervalInSeconds: 180
sessionMaxIdleTimeInSeconds: 300
newSessionMaxWaitTimeInSeconds: 600
environments:
- name: "Firefox on Windows"
browser: "*firefox"
...
I am starting the node via
java -jar selenium-server -standalone-2.42.0.jar -role node -hub http://localhost:4444/grid/register -port 8888 -browser "browserName=Firefox on windows,maxInstances=1,version=1,platform=WINDOWS"
My Test setup looks like this:
public static void main(String[] args) throws MalformedURLException {
System.setProperty("webdriver.ie.driver","C:\\IEDriverServer.exe");
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setBrowserName("*firefox");
RemoteWebDriver remoteWebDriver = new RemoteWebDriver(new URL("http://127.0.0.1:4444" + "/wd/hub"), cap);
}
If i run my test i get the following error:
Exception in thread "main" org.openqa.selenium.WebDriverException: Error forwarding
the new session webdriver new session JSON response body did not contain a session ID
Command duration or timeout: 946 milliseconds
Build info: version: '2.41.0', revision: '3192d8a6c4449dc285928ba024779344f5423c58', time: '2014-03-27 11:29:39'
System info: host: 'CL-CNU416C97F', ip: '10.11.112.158', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_55'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
In the webdriver node i get the important error:
Exception: The path to the driver executable must be set by the webdriver.ie.driver system property...
I have set this property via java and in my windows environment. I do not know why i am still getting this error message.
UPDATE
If i use the grid2 config file (json), how is it possible to set an individual browser by name on each host.
Example:
hub:
port: 4444
remoteControlPollingIntervalInSeconds: 180
sessionMaxIdleTimeInSeconds: 300
newSessionMaxWaitTimeInSeconds: 600
environments:
- name: "MyFireFox on MyMachine1"
browser: "*firefox"
- name: "MyFireFox on MyMachine2"
browser: "*firefox"
If i use this hub config i can start a node by saying it is a "MyFireFox on MyMachine1" Browser. The attribute browser is telling webdriver to use Firefox on the system
If i now use the grid2 config json, i have the following
{
"capabilities":
[
{
"browserName": "MyFireFox on MyMachine1",
"platform": "WINDOWS",
"maxInstances": 1
},
but this will not work, because i think the browserName is what browser was in grid1 config.

this is config from my .bat files. also, why do you change your node port to 8888 ? try to remove '-port 8888' and check again
for hub:
java -jar path_to_selenium-server-standalone-2.41.0.jar -role hub
for node:
java -jar path_to_selenium-server-standalone-2.41.0.jar -role node -hub http://localhost:4444/grid/register -browser browserName=firefox, platform=WINDOWS
here is my json and bat file which 100% works
{
"capabilities":
[
{
"browserName": "firefox",
"platform": "WINDOWS",
"maxInstances": 1
},
{
"browserName": "internet explorer",
"version": "10",
"platform": "WINDOWS",
"maxInstances": 1
}
],
"configuration":
{
"nodeTimeout":120,
"port":5555,
"hubPort":4444,
"hubHost":"192.168.3.104",
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":30000,
"maxSession":1
}
}
and bat to start node from json
java -jar selenium-server-standalone-2.41.0.jar -role node -nodeConfig nodeConfig_win7.json
also in system PATH you should add path to folder with drivers for browsers

Related

System.InvalidOperationException : Unable to create new service: ChromeDriverService with ChromeDriver and SeleniumGrid on local machine

I had set up Selenium Grid (Both Hub and Node) on my local machine which runs on Windows 10 using below command for registering Hub.
java -jar selenium-server-standalone-3.141.59.jar -role hub
and for registering a Node, I had used below command
java -jar selenium-server-standalone-3.141.59.jar -role node -hub http://10.37.34.2:4444/grid/register -port 5454
On Command Prompt, it displayed that "The node is registered to the hub and ready to use"
Verified Grid Console as well at http://localhost:4444/grid/console.
Everything looked fine.
When I executed a simple test case in visual studio, I saw the below error message.
Result Message:
System.InvalidOperationException : Unable to create new service: ChromeDriverService
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'PCD-F3FD2', ip: '10.37.34.2', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_172'
Driver info: driver.version: unknown (SessionNotCreated)
On the Hub Command Prompt, I can see
"20:47:46.539 INFO [RequestHandler.process] - Got a request to create a new session: Capabilities {browserName: chrome, goog:chromeOptions: {}, platformName: windows}
20:47:46.542 INFO [TestSlot.getNewSession] - Trying to create a new session on test slot {server:CONFIG_UUID=0c4146b1-d7d9-4f39-91ce-b30c57c53342, seleniumProtocol=WebDriver, browserName=chrome, maxInstances=5, platformName=WIN10, platform=WIN10}"
On the Node Command Prompt, I can see
20:47:46.601 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"goog:chromeOptions": {
},
"platformName": "windows"}
20:47:46.602 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Below is my C# code:
[Test]
public void AccessGoogle()
{
ChromeOptions options = new ChromeOptions();
options.BinaryLocation = #"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
options.PlatformName = PlatformType.Windows.ToString();
IWebDriver d = new RemoteWebDriver(new Uri("http://10.37.34.2:4444/wd/hub"), options.ToCapabilities());
d.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
d.Url = "https://www.google.com/";
}
Could you please help me to understand what went wrong?
I had tweaked my machines Firewall settings as well. But no luck!
As you have set up Selenium Grid (Both Hub and Node) on your local machine, so while initializng the Selenium Grid Node you need to pass the absolute path of the ChromeDriver location through the Dwebdriver.chrome.driver argument as follows:
java -Dwebdriver.chrome.driver=C:\path\to\chromedriver.exe -jar selenium-server-standalone-3.141.59.jar -role node -hub http://10.37.34.2:4444/grid/register -port 5454

'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

How to start remote Safari Technology Preview from Selenese Runner Java

I have here a Selenium Hub and a Selenium Node with Config:
{
"capabilities":
[
{
"browserName": "safari",
"version": "10",
"maxInstances": 1,
"webdriver.safari.driver": "/Applications/Safari\ Technology\ Preview.app/Contents/MacOS/safaridriver"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 1,
"port": 5555,
"register": true,
"registerCycle": 5000,
"hub": "<IP>:4444",
"role": "node",
}
If I try to start a test from a Maven project with the code:
SafariOptions safariOptions = new SafariOptions();
safariOptions.setUseTechnologyPreview(true);
safariOptions.setUseCleanSession(true);
DesiredCapabilities capabilities = DesiredCapabilities.safari();
capabilities.setCapability(SafariOptions.CAPABILITY, safariOptions);
RemoteWebDriver driver = new RemoteWebDriver(
new URL("http://172.31.4.70:4444/wd/hub"), capabilities);
System.out.println(capabilities.toString());
System.out.println(safariOptions.toJson().toString());
driver.manage().window().maximize();
driver.get("https://check24.de/kredit");
//Close the browser
driver.quit();
On the MAC, the Safari Technology Preview starts no problem.
The Selenium Hub log:
14:02:03.874 INFO - Got a request to create a new session: Capabilities [{browserName=safari, safari.options={technologyPreview=true, port=0, cleanSession=true}, version=, platform=MAC}]
14:02:03.898 INFO - Trying to create a new session on test slot {seleniumProtocol=WebDriver, webdriver.safari.driver=/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver, browserName=safari, maxInstances=1, version=10, platform=MAC}
Now I'd like to start that with Selenese Runner Java with
java -jar C:\selenium\selenese-runner.jar --driver remote --remote-url http://<ip>:4444/wd/hub --remote-platform MAC --remote-browser "safari" --define "safari.options={technologyPreview=true, port=0, cleanSession=true}" --screenshot-on-fail C:\selenium\screenshot --max-time 600 --baseurl %1 %2
The log on the Seleniu Hub is the same:
14:05:26.088 INFO - Got a request to create a new session: Capabilities [{browserName=safari, safari.options={technologyPreview=true, port=0, cleanSession=true}, version=, platform=MAC}]
14:05:26.102 INFO - Trying to create a new session on test slot {seleniumProtocol=WebDriver, webdriver.safari.driver=/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver, browserName=safari, maxInstances=1, version=10, platform=MAC}
But a Safari (NOT Technology Preview) instante starts on the Selenium Node.
The different is that one send the safari.option with safariOption Class and one send it with plain text.
I cannot understand why there is defferent.
Have you any Idea?
Thanks!
Lian Shen

Runnig selenium Grid

I am trying to run a test using the selenium server which will enable cross browser testing, but I'm getting this error
I have downloaded the standalone server and ran it through comand prompt and got a grid console such as the image file attached and my guess is only webdriver part is enabled and remote control part is not if so PLease guid me on how to solve this [Grid console][1]
this is the error
FAILED: test
org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Command duration or timeout: 256 milliseconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'AKHIL-PC', ip: '192.158.0.29', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver
The error suggests that you are missing chrome driver. did you download the chrome driver form here?
Did you add the chrome driver to your path variable
In Windows, goto System -> Advanced System Settings -> Advanced (Tab) -> Environment Variables
Under System variables, scroll to the Variable named Path -> Edit… (button) -> Variable value ->
Scroll to the end of the field, add a semicolon and append the local path of chromedriver.exe to the
end of the value field. Click OK:
To verify, open the Command Line (Run cmd.exe) -> Type chromedriver ->Hit Enter -> ChromeDriver
Also, restart the selenium standalone hubs and nodes
Let me know if it works
EDIT:
And if you configure your node via a xml file like:
{
"capabilities":
[
{
"browserName": "chrome",
"platform": "WINDOWS",
"maxInstances": 5,
"seleniumProtocol": "WebDriver",
"webdriver.chrome.driver": "C:/Selenium/drivers/chromedriver.exe",
"binary":"C:/Program Files/Google/Chrome/Application/chrome.exe"
}
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 5,
"port": 5555,
"register": true,
"registerCycle": 5000,
"hub": "<address to hub>",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {}
}
Change the webdriver.chrome.driver and binary to your own path.
and the to your hub url
And start your node via:
java -jar selenium-server-standalone-<version>.jar -role node -nodeConfig nodeConfig.json

Launch Safari on Mac node from Windows PC with Selenium RemoteWebDriver and Grid

I'm trying to fire off a test to my iMac from my Windows PC.
I have downloaded and installed the webdriver addon for Safari and I have established a connection to my Windows based Selenium Grid hub.
When I try to run my test I receive an error for an OperaDriver:
org.openqa.selenium.WebDriverException: The best matching driver provider org.openqa.selenium.opera.OperaDriver can't create a new driver instance for Capabilities [{browserName=safari, safari.options={port=0, cleanSession=true}, version=9, platform=MAC}]
Current Setup:
Windows PC:
java -jar selenium-server-standalone-2.53.0.jar -role hub -port 4445
Mac:
java -jar selenium-server-standalone-2.53.0.jar -role node -nodeConfig node1Config.json
node1Config:
{
"capabilities": [
{
"browserName": "safari",
"acceptSslCerts": true,
"javascriptEnabled": true,
"takeScreenshot": false,
"browser-version": "9",
"platform": "MAC",
"maxInstances": 5,
"cleanSession": true
}
],
"configuration": {
"_comment": "Configuration for Node",
"cleanUpCycle": 2000,
"timeout": 30000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"port": 5568,
"hubHost": "MyNetworkIpWasHere",
"register": true,
"hubPort": 4445,
"maxSessions": 5
}
}
Java to launch test:
DesiredCapabilities capabilities = DesiredCapabilities.safari();
capabilities.setPlatform(Platform.MAC);
capabilities.setBrowserName("safari");
capabilities.setVersion("9");
webDriver = new RemoteWebDriver(new URL("http://myipwashere:4445/wd/hub"), capabilities);
Edit: There are 5 safari nodes available on my grid, none are being used.
I must be overlooking something, any help would be greatly appreciated!
Thanks in advance.
After much trial and error, the URL being passed to the remotewebdriver was incorrect only for Safari. Hopefully this will help someone that has a similar problem in the future.
Thanks RemcoW for all of your help.