Webdriver-manager error: Unable to create session with *my config* - selenium

I run into the following problem after updating webdriver-manager:
E/launcher - SessionNotCreatedError: Unable to create session from
my config is printed here
webdriver-manager Version: 12.1.5
Node Version: 10.15.3
Protractor Version: 5.4.2
Browser(s): Chrome
Operating System and Version: Win 7 / Ubuntu
This is my config file which worked for the last 1.5 years:
exports.config = {
"seleniumAddress": "http://localhost:4444/wd/hub",
"seleniumPort": "4444",
"capabilities": {
"browserName": "chrome",
"unexpectedAlertBehaviour": "accept",
"perform": "ANY",
"version": "ANY",
"chromeOptions": {
"perfLoggingPrefs": {
"traceCategories": "blink.console,devtools.timeline,disabled-by-default-devtools.timeline,toplevel,disabled-by-default-devtools.timeline.frame,benchmark"
},
"prefs": {
"credentials_enable_service": false
},
"args": ["--headless", "--window-size=800,1080", "--disable-blink-features=BlockCredentialedSubresources", "--no-sandbox", "--test-type=browser", "--disable-dev-shm-usage", "--enable-gpu-benchmarking", "--enable-thread-composting" , "--start-maximized"]
},
"loggingPrefs": { "performance": "ALL" }
},
"jasmineNodeOpts": {
"showColors": true,
"defaultTimeoutInterval": 9999999
},
"allScriptsTimeout": 200000,
"params": {
"perf": {
"selenium": { "protocol": "http:", "slashes": true, "auth": null, "host": "localhost:4444", "port": 4444, "hostname": "localhost", "hash": null, "search": null, "query": null, "pathname": "/wd/hub", "path": "/wd/hub", "href": "http://localhost:4444/wd/hub" },
"browsers": [{
"browserName": "chrome",
"chromeOptions": {
"perfLoggingPrefs": {
"traceCategories": "blink.console,devtools.timeline,disabled-by-default-devtools.timeline,toplevel,disabled-by-default-devtools.timeline.frame,benchmark"
},
"args": ["--headless", "--disable-gpu", "--disable-blink-features=BlockCredentialedSubresources", "--no-sandbox", "--test-type=browser", "--disable-dev-shm-usage"]
},
"loggingPrefs": { "performance": "ALL" }
}],
"debugBrowser": false,
"actions": ["scroll"],
"metrics": ["TimelineMetrics", "ChromeTracingMetrics", "RafRenderingStats", "NetworkTimings", "NetworkResources"],
"metricOptions": {}
},
"warmup": false,
"agilar" : false
}
}
I know the file is a mess and it's more or less googled together, but it worked. Can you point me to what is causing this problem?

Is selenium server up and running at default address
"http://localhost:4444/wd/hub" . If it's not , start it by running : webdriver-manager start. Assuming you have webdriver-manager installed already.
Also I dont think you need to define seleniumPort when you have selenium address property given already in config. So remove this property "seleniumPort": "4444" from config.

Related

In Nightwatchjs, how to use maximum or defined number of instances of browser in a node using Selenium Grid till execution completed

When I execute more than 280 testsuites with 3000+ test cases in parallel using NightwatchJs via Selenium Grid. I have allocated 26 node(running on AWS Fargate) and configured my node to supports 5 instance where total instances are 130 available.
then configured worker=43 in nightwatch.json file like:
{
"src_folders": [
"tests"
],
"output_folder": "reports",
"custom_commands_path": "./custom/commands",
"custom_assertions_path": "",
"page_objects_path": "pages",
"globals_path": "./custom/globals.js",
"live_output": true,
"detailed_output": false,
"selenium": {
"start_process": false,
"server_path": "lib/drivers/selenium-server-standalone-3.9.1.jar",
"selenium_port": 4444,
"screenshots": {
"enabled": false,
"on_failure": false,
"on_error": false,
"path": "screenshots/"
},
"cli_args": {
"webdriver.chrome.driver": ""
}
},
"test_settings": {
"default": {
"launch_url": "someWebsite.com",
"selenium_port": 4444,
"selenium_host": "selenium-abc.selenium.xyz.com",
"silent": true,
"use_xpath": true,
"end_session_on_fail": false,
"skip_testcases_on_fail": false,
"request_timeout_options": {
"timeout": 120000
},
"screenshots": {
"enabled": true,
"path": "screenshots/chrome/",
"on_failure": true,
"on_error": true
},
"desiredCapabilities": {
"browserName": "chrome",
"goog:chromeOptions": {
"w3c": false,
"args": [
"--use-fake-ui-for-media-stream",
"--window-size=1920,1080",
"--disable-gpu",
"--disable-dev-shm-usage",
"--disable-extensions",
"--no-sandbox",
"disable-infobars",
"--start-maximized",
"--whitelisted-ips"
]
}
}
},
"dev": {
"launch_url": "someWebsite.com"
},
"local-chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"w3c": false,
"args": [
"disable-web-security",
"ignore-certificate-errors",
"--test-type"
]
}
}
},
"edge": {
"desiredCapabilities": {
"browserName": "MicrosoftEdge"
}
}
},
"parallel_process_delay": 10000,
"test_workers": {
"enabled": true,
"workers": 43
}
}
nightwatch.conf.js file look like
module.exports = (function (settings) {
//setting up selenium grid server hostname based on arguments passed
if (process.argv.includes("--selenium_host")) {
let arguments = process.argv;
let hostFoundInArgs = false;
arguments.forEach((string, index) => {
if (string.includes("selenium_host") && arguments[index + 1] != undefined) {
hostFoundInArgs = true;
settings.test_settings.default.selenium_host = arguments[index + 1];
}
if (string.includes("workers") && arguments[index + 1] != undefined) {
hostFoundInArgs = true;
let workerStringObject = "{\"enabled\" : true, \"workers\" : "+arguments[index + 1]+"}"
let workers = JSON.parse(workerStringObject);
settings.test_workers = workers;
}
})
}
return settings;
})(require('./nightwatch.json'));
So that it will use 43 browser instances while executions through Jenkins but this is not the case.
At starting it uses around 30 instances but after some time it went down to 4 to 5 instances only or even low because after first batch of testsuites execution completed, it is not able to utilize the rest or free instances available. Due to which our execution time went to around 2 and half hours.
So here is my question, is there any way to utilize all the instances available till completion of execution. So that my resource will not go waste.
Please let me know if more information needed.

Getting console log or geckodriver.log for remote firefox browser

Using below configuration as capabilities for the remote firefox browser(saucelabs)-
12:34:32.312 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "firefox",
"moz:firefoxOptions": {
"profile": "Test1",
"prefs": {
"devtools.chrome.enabled": false,
"media.webrtc.hw.h264.enabled": true,
"media.peerconnection.ice.tcp": true,
"dom.webnotifications.enabled": false,
"media.gmp-manager.updateEnabled": true,
"devtools.console.stdout.content": true,
"media.getusermedia.screensharing.enabled": true,
"devtools.debugger.remote-enabled": true,
"media.peerconnection.video.h264_enabled": true,
"marionette": true,
"media.navigator.permission.disabled": true,
"devtools.debugger.prompt-connection": false,
"media.navigator.streams.fake": true
},
"log": {
"level": "trace"
},
"args": [
"--use-fake-device-for-media-stream",
"--use-fake-ui-for-media-stream",
"--start-maximized",
"--disable-web-security",
"enable-logging",
"-start-debugger-server",
"9222"
]
},
"selenium:webdriver.remote.quietExceptions": false
}
Yet unable to get the console info into the selenium-driver.log in saucelabs. Even setting the option "devtools.console.stdout.content": true also not yielding any file with geckodriver.log.
With the same settings, chrome console logs are being captured as part of selenium-driver.log. Is there anything to be configured for getting console output for remote firefox?
Any input on this is very much appreciated.

goog:chromeOptions being ignored completely using RSpec, Capybara, and Selenium

Is anyone else having this problem? It seems that somewhere goog:chromeOptions are not getting passed to chromedriver properly - which results in Chrome just opening with default options.
I'm using the following Capybara/Selenium configuration:
Capybara.register_driver :chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
'goog:chromeOptions': {
args: %w[ start-maximized ]
}
)
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
desired_capabilities: capabilities,
driver_opts: {
log_path: "./tmp/chrome#{Time.now.to_i}.log",
verbose: true
}
)
end
Capybara.javascript_driver = :chrome
However, when I open up the Capybara session log, the goog:chromeOptions have not been set at all. Is this why my Chrome window is not maximized?
Session log:
[1550680994.143][INFO]: COMMAND InitSession {
"capabilities": {
"firstMatch": [ {
"browserName": "chrome",
"goog:chromeOptions": {
//nothing is here??? should have args!
}
} ]
},
"desiredCapabilities": {
"browserName": "chrome",
"cssSelectorsEnabled": true,
"goog:chromeOptions": {
//nothing is here??? should have args!
},
"javascriptEnabled": true,
"nativeEvents": false,
"platform": "ANY",
"rotatable": false,
"takesScreenshot": false,
"version": ""
}
}
Operating System:
Ubuntu 18.04
My environment:
ruby 2.6.1
capybara (2.18.0)
selenium-webdriver (3.13.0)
ChromeDriver 2.37.544315
Everytime I run a Selenium test, the window is not maximized. But this isn't another "the screen isn't maximized" post (there are lots of those already). This appears to be an issue where my options are not being parsed properly perhaps? I don't get whats wrong. I'm following all the README's and guides as best I can. Its just not working :(
Fixed it by upgrading Capybara and Selenium Webdriver!
capybara (3.13.2)
selenium-webdriver (3.141.0)
Now the debug log has what I was expecting to see:
[1550686685.534][INFO]: COMMAND InitSession {
"capabilities": {
"firstMatch": [ {
"browserName": "chrome",
"goog:chromeOptions": {
"args": [ "start-maximized" ]
}
} ]
},
"desiredCapabilities": {
"browserName": "chrome",
"cssSelectorsEnabled": true,
"goog:chromeOptions": {
"args": [ "start-maximized" ]
},
"javascriptEnabled": true,
"nativeEvents": false,
"platform": "ANY",
"rotatable": false,
"takesScreenshot": false,
"version": ""
}
}

UnknownError: Connection refused (Connection refused)

I'm running a grunt test within a MEAN JS stack app and found an issue that I can't work out its cause.
Running webdriver-manager on its own, i.e. webdriver-manager start, works fine, but running via the grunt test task seems to fail.
I also noticed that the port is different (not 4444). Not sure how to change this either.
Running "protractor:e2e" (protractor) task
webdriver-manager path: /Users/valdy/Development/MeanJSApp/node_modules/protractor/bin/webdriver-manager
selenium standalone is up to date.
chromedriver is up to date.
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://192.168.0.115:64594/wd/hub
/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/atoms/error.js:108
var template = new Error(this.message);
^
UnknownError: Connection refused (Connection refused)
at new bot.Error (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/atoms/error.js:108:18)
at Object.bot.response.checkResponse (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/atoms/response.js:109:9)
at /Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:160:24
at promise.ControlFlow.runInFrame_ (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1857:20)
at wrappedCtr.notify (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2448:25)
at promise.Promise.notify_ (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:564:12)
at Array.forEach (native)
at promise.Promise.notifyAll_ (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:553:15)
at goog.async.run.processWorkQueue (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/async/run.js:130:15)
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)
at Function.webdriver.WebDriver.createSession (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)
at Builder.build (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/builder.js:445:22)
at LocalDriverProvider.DriverProvider.getNewDriver (/Users/valdy/Development/MeanJSApp/node_modules/protractor/lib/driverProviders/driverProvider.js:38:7)
at Runner.createBrowser (/Users/valdy/Development/MeanJSApp/node_modules/protractor/lib/runner.js:182:37)
at /Users/valdy/Development/MeanJSApp/node_modules/protractor/lib/runner.js:263:21
at _fulfilled (/Users/valdy/Development/MeanJSApp/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/Users/valdy/Development/MeanJSApp/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/Users/valdy/Development/MeanJSApp/node_modules/q/q.js:759:13)
at /Users/valdy/Development/MeanJSApp/node_modules/q/q.js:573:44
[launcher] Process exited with error code 1
>>
Warning: Tests failed, protractor exited with code: 1 Use --force to continue.
Aborted due to warnings.
This is the config for tests.js (/config/assets/tests.js):
'use strict';
module.exports = {
tests: {
// client: ['modules/*/tests/client/**/*.js'],
client: ['modules/forum/tests/client/**/*.js'],
// server: ['modules/*/tests/server/**/*.js'],
server: ['modules/forum/tests/server/**/*.js'],
e2e: ['modules/*/tests/e2e/**/*.js']
// e2e: ['modules/forum/tests/e2e/**/*.js']
}
};
I also found that protractor's config.json, under /node_module/protractor/config.json has this configuration:
{
"webdriverVersions": {
"selenium": "2.47.1",
"chromedriver": "2.19",
"iedriver": "2.47.0"
}
}
And this is my own protractor.config.js, in the root of the web app:
'use strict';
// Protractor configuration
var config = {
specs: ['modules/*/tests/e2e/*.js']
};
if (process.env.TRAVIS) {
config.capabilities = {
browserName: 'firefox'
};
}
exports.config = config;
And here is protractor's npm descriptor (/node_module/protractor/package.json):
{
"_args": [
[
{
"raw": "Protractor#2.5.1",
"scope": null,
"escapedName": "Protractor",
"name": "Protractor",
"rawSpec": "2.5.1",
"spec": "2.5.1",
"type": "version"
},
"/Users/valdy/Development/MeanJSApp"
]
],
"_from": "Protractor#2.5.1",
"_id": "protractor#2.5.1",
"_inCache": true,
"_location": "/protractor",
"_nodeVersion": "0.12.7",
"_npmUser": {
"name": "angularcore",
"email": "angular-core+npm#google.com"
},
"_npmVersion": "2.11.3",
"_phantomChildren": {
"boom": "2.10.1",
"chalk": "1.1.3",
"combined-stream": "1.0.5",
"core-util-is": "1.0.2",
"cryptiles": "2.0.5",
"ctype": "0.5.3",
"forever-agent": "0.6.1",
"graceful-readlink": "1.0.1",
"hoek": "2.16.3",
"inherits": "2.0.3",
"is-my-json-valid": "2.16.0",
"isstream": "0.1.2",
"json-stringify-safe": "5.0.1",
"lru-cache": "2.7.3",
"oauth-sign": "0.8.2",
"sigmund": "1.0.1",
"sntp": "1.0.9",
"string_decoder": "0.10.31",
"stringstream": "0.0.5",
"tough-cookie": "2.3.2"
},
"_requested": {
"raw": "Protractor#2.5.1",
"scope": null,
"escapedName": "Protractor",
"name": "Protractor",
"rawSpec": "2.5.1",
"spec": "2.5.1",
"type": "version"
},
"_requiredBy": [
"#USER",
"/grunt-protractor-runner",
"/gulp-protractor"
],
"_resolved": "https://registry.npmjs.org/protractor/-/protractor-2.5.1.tgz",
"_shasum": "03d6c93cd7c268f4250177d55a2fec8a198372cd",
"_shrinkwrap": null,
"_spec": "Protractor#2.5.1",
"_where": "/Users/valdy/Development/MeanJSApp",
"author": {
"name": "Julie Ralph",
"email": "ju.ralph#gmail.com"
},
"bin": {
"protractor": "bin/protractor",
"webdriver-manager": "bin/webdriver-manager"
},
"bugs": {
"url": "https://github.com/angular/protractor/issues"
},
"dependencies": {
"accessibility-developer-tools": "~2.6.0",
"adm-zip": "0.4.4",
"glob": "~3.2",
"html-entities": "~1.1.1",
"jasmine": "2.3.2",
"jasminewd": "1.1.0",
"jasminewd2": "0.0.6",
"lodash": "~2.4.1",
"minijasminenode": "1.1.1",
"optimist": "~0.6.0",
"q": "1.0.0",
"request": "~2.57.0",
"saucelabs": "~1.0.1",
"selenium-webdriver": "2.47.0",
"source-map-support": "~0.2.6"
},
"description": "Webdriver E2E test wrapper for Angular.",
"devDependencies": {
"chai": "~3.3.0",
"chai-as-promised": "~5.1.0",
"cucumber": "~0.6.0",
"expect.js": "~0.2.0",
"express": "~3.3.4",
"jshint": "2.5.0",
"mocha": "2.3.3",
"rimraf": "~2.2.6"
},
"directories": {},
"dist": {
"shasum": "03d6c93cd7c268f4250177d55a2fec8a198372cd",
"tarball": "https://registry.npmjs.org/protractor/-/protractor-2.5.1.tgz"
},
"gitHead": "645133d557f1059d9e885f2566fc4c29ce7c19cc",
"homepage": "https://github.com/angular/protractor",
"keywords": [
"angular",
"test",
"testing",
"webdriver",
"webdriverjs",
"selenium"
],
"license": "MIT",
"main": "lib/protractor.js",
"maintainers": [
{
"name": "juliemr",
"email": "ju.ralph#gmail.com"
},
{
"name": "angularcore",
"email": "angular-core+npm#google.com"
}
],
"name": "protractor",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/angular/protractor.git"
},
"scripts": {
"pretest": "jshint lib spec scripts",
"start": "node testapp/scripts/web-server.js",
"test": "node scripts/test.js"
},
"version": "2.5.1"
}
Here is my best guess at what's going on:
You are launching with the selenium standalone server locally using your ip address and a port that is not 4444. This means that you did not select seleniumAddress: "http://localhost:4444/wd/hub" or directConnect: true. I'll have a code snippet below of what this looks like.
If you are launching locally and not on Travis, then Protractor launches by the Chrome browser by default. This also means that you should have downloaded the ChromeDriver.
You should upgrade from Protractor 2.5 to the latest. Protractor is strongly coupled with the entire stack: selenium-webdriver, the standalone server, browser drivers and browsers. If you are using an up-to-date browser and Protractor 2.5, then probably webdriver-manager downloaded old binaries that may be incompatible with your browser.
Here is the code snippet:
exports.config = {
// option 1. launches a selenium standalone server. this is helpful if
// you launch it with "webdriver-manager start"
// seleniumAddress: "http://localhost:4444/wd/hub",
//
// option 2. launch browser directly using browser binaries
// directConnect: true,
//
// option 3. do not include either seleniumAddress or directConnect
// and this option will launch the selenium standalone server using
// your ip address.
//
// option 4: launch with saucelabs or browserstack options
}
This file relates to this one where you define your config, set capabilities only for travis and export the config.
'use strict';
// Protractor configuration
var config = {
specs: ['modules/*/tests/e2e/*.js']
};
if (process.env.TRAVIS) {
config.capabilities = {
browserName: 'firefox'
};
}
exports.config = config;

microsoft edge and nightwatch

for some reason, I have not been able to get tests working in Microsoft Edge Windows 10.
Here's my nightwatch config
"edge": {
"use_ssl": false,
"silent": true,
"output": true,
"desiredCapabilities": {
"browserName": "MicrosoftEdge",
"platform": "Windows 10",
"version": "13.10586",
"screenResolution": "1280x1024",
"avoidProxy": true
}
}
Has anyone been able to get their tests working in Microsoft Edge?
If so, what version of selenium do you use? I use 2.52
What version of the edge driver do you use?
First of all you need Microsoft Edge Webdriver. You may download it from here: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Then in nigthwatch.js config you need to specify path to you edge webdriver (webdriver.edge.driver arg). This is how my config looks like:
"selenium": {
"start_process": true,
"server_path": "./node_modules/file_dependencies/selenium-server-standalone.jar",
"log_path": "",
"host": "127.0.0.1",
"port": seleniumPort,
"cli_args": {
"webdriver.chrome.driver": "./node_modules/file_dependencies/chromedriver.exe",
"webdriver.ie.driver": "./node_modules/file_dependencies/IEDriverServer.exe",
"webdriver.edge.driver": "C:/Program Files (x86)/Microsoft Web Driver/MicrosoftWebDriver.exe",
"webdriver.gecko.driver": "./node_modules/file_dependencies/geckodriver.exe",
"webdriver.firefox.profile": ""
}
}
Rest of your config looks fine
I had issues getting edge to work using Selenium 3.9.1 where Selenium was attempting to use the geckodriver to run tests against Edge.
My configuration looked as follows (snippet to keep to the point):
"selenium" : {
"cli_args" : {
"webdriver.chrome.driver" : "bin\\chromedriver.exe",
"webdriver.edge.driver" : "bin\\MicrosoftWebDriver.exe",
"webdriver.gecko.driver" : "bin\\geckodriver.exe",
"webdriver.firefox.profile": ""
}
},
"test_settings" : {
"default" : {
"desiredCapabilities": {
"browserName": "edge",
"marionette": true
}
}
}
I was able to get around this by changing "edge" to "ie" and the browser name to "internet explorer" - see the updated configuration:
"selenium" : {
"cli_args" : {
"webdriver.chrome.driver" : "bin\\chromedriver.exe",
"webdriver.ie.driver" : "bin\\MicrosoftWebDriver.exe",
"webdriver.gecko.driver" : "bin\\geckodriver.exe",
"webdriver.firefox.profile": ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities": {
"browserName": "internet explorer",
"marionette": true
}
}
}
The auto-generated nightwatch.conf.js already includes configuration for Edge browser, so you can just run by flagging the edge environment:
nightwatch --env edge