Cannot execute protractor tests using headless chrome on Selenium Grid nodes - selenium

I'm using Selenium server 3.8.1, with the hub and 2 nodes.
The hub and each node are executed on different machines.
Currently, I can launch the tests and they're working fine. But, I'm not able to make the headless mode run.
My config JSON only contains the capabilities object.
{
"capabilities":
[{
"browserName": "chrome",
"maxInstances": 3,
"seleniumProtocol": "WebDriver",
"chromeOptions": {
"args": [
"--headless",
"--disable-gpu",
"--window-size=1920x1080"]
}}]
}
I launch the selenium nodes using a .bat that contains the following command:
"C:\Program Files\Java\jre1.8.0_181\bin\java" -jar C:\jobs\selenium-node\selenium-server-standalone-3.8.1.jar -role node -hub http://172.16.0.5:5555/grid/register -port 5558 -nodeConfig config.json -maxSession 3
The selenium node works fine and appears on the selenium grid UI. Also, the capabilities of the chrome driver include the --headless and other parameters:
....
capabilities: Capabilities {browserName: chrome, chromeOptions: {args: [--headless, --disable-gpu, --window-size=1920x1080]}, maxInstances: 3, platform: XP, se:CONFIG_UUID: cdc21610-4c47-4d23-9478-a20..., seleniumProtocol: WebDriver}
....
On the protractor.conf file I have these capabilities, that work when I run the tests locally.
seleniumAddress:'http://172.16.0.5:5555/wd/hub',
getPageTimeout: 120000,
allScriptsTimeout: 120000,
ignoreUncaughtExceptions: true,
chromeOnly:true,
directConnect: false,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
"javascriptEnabled": true,
"acceptSslCerts": true,
"browserName": "chrome",
"chromeOptions": {
"args": [ "--headless", "--disable-gpu", "--window-size=1920,1080"]
}
},
But, when I launch the tests, the chrome driver isn't executed on headless mode. Works fine, but the different windows keep appearing.
Environment details:
chromedriver version: 2.36.540470
chrome version: 69.0.3497.100

As per your question/comment update you are using:
chromedriverVersion: '2.36.540470, chrome version' => '69.0.3497.100'
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.36
Release Notes of chromedriver=2.36 clearly mentions the following :
Supports Chrome v63-65
You are using chrome=69.0
Release Notes of ChromeDriver v2.42 clearly mentions the following :
Supports Chrome v68-70
So there is a clear mismatch between the ChromeDriver v2.36 and the Chrome Browser v69.0
Solution
Upgrade Selenium to current levels Version 3.14.0.
Upgrade ChromeDriver to current ChromeDriver v2.42 level.
Keep Chrome version between Chrome v68-70 levels. (as per ChromeDriver v2.42 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.

Related

why It show me This version of ChromeDriver only supports Chrome version 104?

when I use wdio for e2e tests, I got an exception.But my chromedriver is 106.0.1.
[0-1] 2022-10-24T10:58:18.928Z ERROR webdriver: Request failed with status 500 due to session not created: session not created: This version of ChromeDriver only supports Chrome version 104
[0-1] Current browser version is 106.0.5249.119 with binary path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
but when I check chromedriver:
chromedriver -v
ChromeDriver 106.0.5249.61 (511755355844955cd3e264779baf0dd38212a4d0-refs/branch-heads/5249#{#569})
I has been tried all those methods:
SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81.
But I still got same exception.please help me.
My configureation:
module.exports.config = {
runner: "local",
path: "/wd/hub",
specs: ["./test/specs/*.js"],
maxInstances: 1,
capabilities: [
{
pageLoadStrategy: "none",
maxInstances: 1,
//
browserName: "chrome",
"goog:chromeOptions": {
excludeSwitches: ["enable-automation"],
},
},
],
logLevel: "warn",
bail: 0,
baseUrl: "http://localhost:3333",
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
services: ["chromedriver"],
framework: "mocha",
reporters: ["spec"],
}
I resolve this question by configure path.
services: [
[
"chromedriver",
{
chromedriverCustomPath: "/usr/local/bin/chromedriver",
},
],
],
I solved this problem by configuring the path. But I don't think this is a good method, because it means that any participant who uses this testing function needs to set the chromedriver in this path.
In fact, another project with the same npm version and my other configuration can run normally without configuring the path. This is really strange! This shows that my local chromedriver has no problems and can run directly.

protractor/selenium started ignoring the chrome options (chromeOptions) in protractor.conf.js

I just rebuilt our development environment. This forced the latest version of chrome and suddenly the protractor based tests stopped working. After some research, I tracked this down to the fact that our chrome options in the protractor configuration file are now ignored.
Here is the configuration that used to work fine before:
exports.config = {
...
multiCapabilities : [
{
browserName: "chrome",
chromeOptions: {
args: [
"--disable-gpu",
"--headless",
'--no-sandbox',
"--incognito"
]
}
},
},
],
...
};
Before After
protractor 6.0.0 6.0.0
selenium 4.0.0-alpha-1 4.0.0-alpha-1
chrome 74.0.3729.157 76.0.3809.100
chromedriver 74.0.3729.6 76.0.3809.68
In recent versions of selenium you have to specify the chrome options as goog:chromeOptions. So just change the chromeOptions line above to the following:
...
"goog:chromeOptions": {
...
and you are back in business.
"chromeOptions": {}
its still usable in most cases, but does not support new arguments provided by chrome
suggested to use
"goog:chromeOptions": {}
Ref to doc: http://chromedriver.chromium.org/capabilities
Same rule for firefox
"moz:firefoxOptions": {}
Ref to doc: https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities/firefoxOptions

Selenium Grid 3 node startup ignoring -nodeconfig node.json

I'm just setting up a new Selenium Grid, and have just one node to register to my hub at the moment. Both hub and node running on CentOS 7. I have two different versions of Firefox on my node, and no other browser, as I will be setting up different nodes for different browser types.
If I start the node completely from the command line, specifying the different Firefox versions and locations, it all registers and starts properly. On the Grid console page I see my node with the two versions of Firefox, 3 instances of each, correctly detailed with the version numbers I'm specifying. This is the command line I use:
java -jar selenium-server-standalone.jar -role node -hub http://xx.xx.xx.xx:4444/grid/register -browser browserName=firefox,version=50.1.0,maxInsfirefox_binary=/opt/firefox-50.1.0/firefox,maxInstances=3,platform=LINUX -browser browserName=firefox,version=51.0.1,firefox_binary=/opt/firefox-51.0.1/firefox,maxInstances=3,platform=LINUX
If however I try using a .json config file to specify my parameters, the java startup completely ignores the config file and starts up using defaults; on the Grid console page it shows 5 Firefox sessions, 1 IE and 5 Chrome, and none of the Firefox sessions show the versions I'm specifying. This is the command line invoking the json file:
java -jar selenium-server-standalone.jar -role node -hub http://xx.xx.xx.xx:4444/grid/register -nodeConfig /opt/selenium/node.json
... and this is the node.json file itself:
{
“capabilities”:
[
{
"browserName": firefox,
"firefox_binary": "/opt/firefox-50.1.0/firefox",
"maxInstances": 3,
"platform": LINUX,
"version": 50,
"seleniumProtocol": WebDriver
},
{
"browserName": firefox,
"firefox_binary": "/opt/firefox-51.0.1/firefox",
"maxInstances": 3,
"platform": LINUX,
"version": 51,
"seleniumProtocol": WebDriver
},
],
“maxSession”: 5,
“port”: 5555,
"hub": "http://xx.xx.xx.xx:4444",
“register”: true,
"registerCycle": 5000,
"nodeStatusCheckTimeout": 5000,
"role": node,
"cleanUpCycle": 2000
}
I have tried putting all parameters encased in double quotation marks, in case that was the issue; made no difference.
Any clues why the parameters in my node.json file are being ignored, please?

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.

Error while registering node in selenium grid

I am getting below error while starting node for selenium grid-
Default driver org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}]
does not match with current platform: MAC
My local system that is hub contains MAC and FIREFOX
Below the configuration of my node(VM).My scripts are on my local machine that is hub-
{
"class": "org.openqa.grid.common.RegistrationRequest",
"capabilities": [
{
"seleniumProtocol": "WebDriver",
"browserName": "firefox",
"version": "25.0.1",
"maxInstances": 1,
"platform" : "LINUX"
}
],
}
Please suggest needful.
There might be two obvious errors:
In your code, you state Platform as Linux but you are running on MAC
The same might be on the node setup. If you run node on mac and then request for Internet Explorer on Windows, it will be simply skipped, hence there is no node running on Windows...