WebDriverException: Error forwarding the new session webdriver new session JSON response body did not contain a session ID - selenium-grid

I am using selenium grid with 1 hub and 2 node, When i am executing script getting this error:
rg.openqa.selenium.WebDriverException: Error forwarding the new session webdriver new session JSON response body did not contain a session ID
Command duration or timeout: 509 milliseconds
Build info: version: '2.42.0', revision: '5e824302019c86eae9c8c3ca9155e7307b410cf8', time: '2014-05-24 09:48:41'
System info: host: 'WIN-PNKGI9TOHPD', ip: '192.168.1.206', os.name: 'Windows Server 2012 R2', os.arch: 'amd64', os.version: '6.3', java.version: '1.7.0_55'
Driver info: org.openqa.selenium.remote.RemoteWebDriver.
I am using POM structue.
here is my Json node congif file:
{
"capabilities":
[
{
"browserName": "chrome",
"maxInstances": 2,
"node": "b"
},
{
"browserName": "firefox",
"maxInstances": 2
},
{
"browserName": "internet explorer",
"maxInstances": 1
}
],
"configuration":
{
"nodeTimeout":1200000,
"port":5555,
"hubPort":4444,
"hubHost":"http://192.168.1.206",
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":50000,
"maxSession":5,
}

Related

How to run an acceptance test in Codeception in Opera Browser?

When I run the test, Opera opens, but the test does not run and an error falls into the console
[Facebook\WebDriver\Exception\SessionNotCreatedException] Unable to create session from {
"desiredCapabilities": {
"browserName": "opera"
},
"capabilities": {
"firstMatch": [
{
"browserName": "opera"
}
]
}
}
Driver info: driver.version: unknown
I start the server with this command:
java "-Dwebdriver.opera.driver=C:\Users\user\Desktop\Auto\qa-tests\Codeception\operadriver.exe" -jar "C:\Users\user\Desktop\Auto\qa-tests\Codeception\selenium-server-standalone-3.14.0.jar"
My acceptance.suite.yaml
opera:
modules:
config:
PhpBrowser:
url: 'https://sample.com/'
WebDriver:
url: 'https://samlpe.com/'
window_size: 1900x1080 # for fullscreen shots
port: 17570
browser: opera # 'chrome' or 'firefox' java "-Dwebdriver.opera.driver=C:\Users\user\Desktop\Auto\qa-tests\Codeception\operadriver.exe" -jar "C:\Users\user\Desktop\Auto\qa-tests\Codeception\selenium-server-standalone-3.14.0.jar" -port 17570 - для MicrosoftEdge
#capabilities:
args: [ '--no-sandbox' ]

How to handle when electron app and chrome browser capabilities require different versions of chromedriver

My test environment has below setup:
#wdio/selenium-standalone-service": "^6.11.0"
node12 (so wdio-electron-service is not an option at the
moment)
google chrome version 102.0.5005.61
electron(#18) app version 100.0.4896.60
firefox version 101.0
By using selenium-standalone service, I am trying to create 1 electron and 1 chrome browser sessions with below 2 capabilities:
Capability #1 - electron session
capabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
binary: 'Path to Electron binary’
args: [
/* cli arguments */
], // Optional, perhaps 'app=' + /path/to/your/app/
},
},
Capability #2 - chrome browser session
capabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
args: […],
},
With selenium-standalone service, if I have following chromedriver version in installArgs and args:
drivers: {
chrome: { version: '100.0.4896.60' },
},
Capability#2 would fail to create session for chrome browser.
If I have
drivers: {
chrome: { version: 'latest' },
},
Capability#1 would fail to create session for electron app
I also tried setting the capability #2 to firefox browser instead of chrome:
capabilities: {
browserName: 'firefox'
}
with selenium-standalone installArg and args:
drivers: {
chrome: { version: '100.0.4896.60' }, // match electron app version
firefox: { version: 'latest' }, // match firefox browser version
}
Electron app session was created but firefox session still failed to create with below error:
[0-0] 2022-06-03T07:48:28.519Z ERROR #wdio/runner: Error: Failed to create session.
Unable to create session from {
"desiredCapabilities": {
"moz:firefoxOptions": {
"args": [
"-remote-debugging-port",
"50030"
]
},
"browserName": "firefox"
},
"capabilities": {
"firstMatch": [
{
"browserName": "firefox",
"moz:firefoxOptions": {
"args": [
"-remote-debugging-port",
"50030"
]
}
}
]
}
}
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '-----', ip: '----', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.16', java.version: '1.8.0_231'
Driver info: driver.version: unknown
at Object.startWebDriverSession (~/node_modules/webdriver/build/utils.js:34:15)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Any suggestions on workaround would be appreciated.
Thank you
It seems like I cannot have multiple versions of chromedriver but I can get the Capability#2 to work by changing to firefox. I was having above driver unknown error because I specified the selenium version 3.141.59 in args but not in installArgs. Once removing/adding 3.141.59 from both args and installArgs, Firefox was working as expected. Please see below:
'selenium-standalone',
{
logPath: 'logs',
installArgs: {
version: '3.141.59',
drivers: {
chrome: { version: '100.0.4896.60' },
firefox: { version: '0.30.0' },
},
},
args: {
version: '3.141.59',
drivers: {
chrome: { version: '100.0.4896.60' },
firefox: { version: '0.30.0' },
},
},
},

Webdriverio selenium standalone doesn't update driver version

I made little demo projects with WebdriverIO 6, Typescript and cucumber.
I have put this in the configuration file wdio.CHROME.conf.ts:
import { config } from './wdio.conf';
import { CHROME_ARGS } from './chrome-args';
const seleniumConfig = {
version: '3.141.59',
drivers: { chrome: { version: '87.0.4280.20' } },
};
const browserOptions: WebDriver.ChromeOptions & { args: Array<string> } = {
args: [
...CHROME_ARGS,
...(process.argv.includes('--headless') ? ['--headless', '--no-sandbox'] : []),
'--window-size=1920,1080',
],
};
const seleniumOpts = config.services?.find(
(service) => Array.isArray(service) && service[0] === 'selenium-standalone'
) as SeleniumStandaloneOptions;
seleniumOpts.args = { ...seleniumConfig };
seleniumOpts.installArgs = { ...seleniumConfig };
console.log(seleniumOpts);
const browserConfig: WebdriverIO.Config = {
...config,
capabilities: [
{
browserName: 'chrome',
'goog:chromeOptions': browserOptions,
},
],
};
exports.config = browserConfig;
And this in wdio.conf.ts:
import * as path from 'path';
import * as appRoot from 'app-root-path';
import { commandsFactory } from './commands-factory';
export const config: WebdriverIO.Config = {
specs: [
'./src/features/**/*.feature',
// './src/features/login.feature',
// './src/features/dashboard.feature'
],
exclude: [
],
maxInstances: 1,
logLevel: 'trace',
bail: 0,
baseUrl: 'http://automationpractice.com',
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
services: [
[
'selenium-standalone',
{
logs: 'logs',
},
],
],
outputDir: path.join(appRoot.path, '/logs'),
framework: 'cucumber',
reporters: [
'spec',
[
'allure',
{
outputDir: 'allure-results',
disableWebdriverStepsReporting: true,
disableWebdriverScreenshotsReporting: false,
useCucumberStepReporter: true,
},
],
],
cucumberOpts: {
backtrace: false,
failAmbiguousDefinitions: true,
failFast: false,
ignoreUndefinedDefinitions: false,
name: [],
snippets: false,
source: true,
profile: [],
require: [
'./src/step_definitions/*.ts',
],
snippetSyntax: undefined,
strict: true,
tagExpression: 'not #Login',
tagsInTitle: false,
timeout: 60000,
},
before(capabilities, specs) {
const commands = commandsFactory({ waitForTimeout: this.waitforTimeout });
/* eslint-disable */
const chai = require('chai');
global.should = chai.should();
// Sample command
function browserCustomCommandExample(text) {
console.log(text);
}
browser.addCommand('browserCustomCommandExample', browserCustomCommandExample);
Object.keys(commands).forEach((key) => {
browser.addCommand(key, commands[key]);
});
},
afterStep(step, context, { error, result, passed, duration }) {
if (error) {
browser.takeScreenshot();
}
},
};
But after I do npm install and try to run tests npm run test:chrome:headless, I get this error:
[0-0] Error: Failed to create session.
session not created: This version of ChromeDriver only supports Chrome version 85
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'LAPTOP-QUTK6LBV', ip: '192.168.1.8', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_271'
Driver info: driver.version: unknown
I have tried to update version of the driver in wdio.CHROME.conf.ts to 87, but it didn't help.
It just doesn't download version 87 of chrome driver, instead it is stuck with version 85.
When I look at the node_modules\selenium-standalone\.selenium\chromedriver there is only version 85 and it wouldn't download the version 87 (85 was previous version I had in configuration file).
On my machine, chrome browser version is 87 and it needs the same version of chrome driver in order to work (from my understanding :D )
I tried deleting node_modules and doing it from scratch but with no success.
This is link to my repo https://github.com/mareru/webdriverIO-shop-demo
Can someone please help :)
Thanks!
I replaced these lines:
const seleniumOpts = config.services?.find(
(service) => Array.isArray(service) && service[0] === 'selenium-standalone'
) as SeleniumStandaloneOptions;
seleniumOpts.args = { ...seleniumConfig };
seleniumOpts.installArgs = { ...seleniumConfig };
With these ones
config.services = [
[
'selenium-standalone',
{
logs: 'logs',
args: seleniumConfig,
installArgs: seleniumConfig,
},
],
];
And it worked. It seems like previous code didn't generate the curly braces well.
Parameters logs, args, installArgs should have been in joint curly brace not in separate curly braces.
It generated this:
[
'selenium-standalone',
{ logs: 'logs' },
args: { version: '3.141.59', drivers: [Object] },
installArgs: { version: '3.141.59', drivers: [Object] }
]
]
While it should have been like this
[
[
'selenium-standalone',
{ logs: 'logs', args: [Object], installArgs: [Object] }
]
]

Webdriver.io - can not get firefox to run

I am trying to get firefox to run in webdriver.io 5. This is on a Linux cloud.
I get:
2020-02-28T02:32:33.472Z INFO #wdio/cli:launcher: Run onPrepare hook
2020-02-28T02:32:33.475Z INFO #wdio/local-runner: Start worker 0-0 with arg: wdio.conf.js
[0-0] 2020-02-28T02:32:33.818Z INFO #wdio/local-runner: Run worker command: run
[0-0] RUNNING in firefox - /build/main.js
[0-0] 2020-02-28T02:32:33.881Z INFO webdriverio: Initiate new session using the webdriver protocol
[0-0] 2020-02-28T02:32:33.883Z INFO webdriver: [POST] http://127.0.0.1:4444/session
[0-0] 2020-02-28T02:32:33.883Z INFO webdriver: DATA {
capabilities: {
alwaysMatch: { browserName: 'firefox', 'moz:firefoxOptions': [Object] },
firstMatch: [ {} ]
},
desiredCapabilities: { browserName: 'firefox', 'moz:firefoxOptions': { args: [Array] } }
}
[0-0] 2020-02-28T02:32:33.899Z WARN webdriver: Request failed due to connect ECONNREFUSED 127.0.0.1:4444
[0-0] 2020-02-28T02:32:33.899Z INFO webdriver: Retrying 1/3
Here is my config:
exports.config = {
runner: 'local',
path: '/',
specs: [
'./build/**/*.js'
],
maxInstances: 10,
capabilities: [
{
"browserName": "firefox",
"moz:firefoxOptions": {
"args": ["-headless"],
}
}
],
logLevel: 'info',
bail: 0,
baseUrl: 'http://localhost',
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
reporters: ['spec'],
framework: 'mocha',
mochaOpts: {
ui: 'bdd',
timeout: 60000
},
services: [
],
}```
Any ideas what I am doing wrong?
The path should be set to path: "/wd/hub" and your services seems to be empty. You can use webdriverio with mocha in two different ways. With selenium or without.
Please refer to boiler plates from official docs here
[0-0] 2020-02-28T02:32:33.899Z WARN webdriver: Request failed due to connect ECONNREFUSED 127.0.0.1:4444
If you are using selenium-standalone, please make sure that you have both the java jdk & sdk installed on your machine. let me know if this worked for you.

Unable to create firefox section selenium grid which is hosted on docker

Please check the details below:
I update - geckodriver: geckodriver-v0.20.1 up to date
Error:
firefox_1 | 11:39:06.089 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session a16899ff-8ef3-40b4-a7a3-406861b95c50 (org.openqa.selenium.firefox.GeckoDriverService)
nodeSetup_1 | [e2e] [11:39:06] E/launcher - Unable to parse new session response: {"value":{"sessionId":"a16899ff-8ef3-40b4-a7a3-406861b95c50","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"60.0.2","moz:accessibilityChecks":false,"moz:headless":false,"moz:processID":71,"moz:profile":"/tmp/rust_mozprofile.EvUy5THtLClM","moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"pageLoadStrategy":"normal","platformName":"linux","platformVersion":"3.19.0-25-generic","rotatable":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"webdriver.remote.sessionid":"a16899ff-8ef3-40b4-a7a3-406861b95c50"}}}
nodeSetup_1 | [e2e] [11:39:06] E/launcher - WebDriverError: Unable to parse new session response: {"value":{"sessionId":"a16899ff-8ef3-40b4-a7a3-406861b95c50","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"60.0.2","moz:accessibilityChecks":false,"moz:headless":false,"moz:processID":71,"moz:profile":"/tmp/rust_mozprofile.EvUy5THtLClM","moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"pageLoadStrategy":"normal","platformName":"linux","platformVersion":"3.19.0-25-generic","rotatable":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"webdriver.remote.sessionid":"a16899ff-8ef3-40b4-a7a3-406861b95c50"}}}
nodeSetup_1 | [e2e] at doSend.then.response (/usr/src/app/serenityjs/node_modules/selenium-webdriver/lib/http.js:445:19)
Code
Protractor conf:
multiCapabilities: [
{
browserName: 'firefox',
firefoxOptions: {
args: ['--headless',
'seleniumProtocol=Selenium'
]
},
'moz:firefoxOptions': {
args: [ '--headless',
'seleniumProtocol=Selenium'
]
}
}
],
Probably you set up capabilities in a wrong way. Try this one:
capabilities: {
'browserName': 'firefox',
'moz:firefoxOptions': {
'args': ['--headless']
}
},