Not able to run basic test using webdriver IO - webdriver-io

I am new to webdriver I am trying to run following code
var assert = require('assert');
describe('webdriver.io page', function() {
it('should have the right title', function () {
browser.url('/');
var title = browser.getTitle();
assert.equal(title,'WebDriverIO - Selenium 2.0 javascript bindings for nodejs');
});
});
When I am trying to run $npm test it is giving me following exception
> web-wedio#1.0.0 test /Users/user_namej/Downloads/web-wedio
> wdio
A service failed in the 'onPrepare' hook
Error: Selenium exited before it could start
Another Selenium process may already be running or your java version may be out of date.
Be sure to check the official Selenium release notes for minimum required java version: https://raw.githubusercontent.com/SeleniumHQ/selenium/master/java/CHANGELOG
at ChildProcess.errorIfNeverStarted (/Users/user_namej/Downloads/web-wedio/node_modules/selenium-standalone/lib/start.js:158:10)
at ChildProcess.emit (events.js:159:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
Continue...
[23:57:43] COMMAND POST "/wd/hub/session"
ERROR: Error forwarding the new session Empty pool of VM for setup Capabilities [{rotatable=true, locationContextEnabled=true, loggingPrefs=org.openqa.selenium.logging.LoggingPreferences#9288a03, browserName=firefox, javascriptEnabled=true, handlesAlerts=true, maxInstances=5, requestOrigins={name=webdriverio, version=4.13.1, url=http://webdriver.io}}]
firefox
at new RuntimeError (/Users/user_namej/Downloads/web-wedio/node_modules/webdriverio/build/lib/utils/ErrorHandler.js:143:12)
at Request._callback (/Users/user_namej/Downloads/web-wedio/node_modules/webdriverio/build/lib/utils/RequestHandler.js:316:39)
at Request.self.callback (/Users/user_namej/Downloads/web-wedio/node_modules/request/request.js:185:22)
at Request.emit (events.js:159:13)
at Request.<anonymous> (/Users/user_namej/Downloads/web-wedio/node_modules/request/request.js:1157:10)
at Request.emit (events.js:159:13)
at IncomingMessage.<anonymous> (/Users/user_namej/Downloads/web-wedio/node_modules/request/request.js:1079:12)
at Object.onceWrapper (events.js:254:19)
at IncomingMessage.emit (events.js:164:20)
at endReadableNT (_stream_readable.js:1062:12)
I try . to shut down server using
http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer
but it is redirecting to 500 error page,Also I tried to do it with different commands
lsof -i :4444
kill -9 $(lsof -ti tcp:4444)
Still not working.What should I do.
Please let me know if more details required

Silly question, but have you checked your java version to see if it's compatible?
If not, maybe this could help explain your problem: https://github.com/SeleniumHQ/selenium/issues/2043

Related

Adjust protractor config to debug in non-headless mode

When executing the protractor test, it succeeds in --headless mode, but when I remove the --headless option, it fails stating: the user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir.
As you can see, I'm not using that particular argument, so I'm not what to do about this.
Update: When the crome browser tab opens, data:, is in the address bar.
Error
$ protractor conf.js
[14:10:17] I/launcher - Running 1 instances of WebDriver
[14:10:17] I/direct - Using ChromeDriver directly...
[14:10:18] E/launcher - invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
(Driver info: chromedriver=79.0.3945.16 (93fcc21110c10dbbd49bbff8f472335360e31d05-refs/branch-heads/3945#{#262}),platform=Windows NT 10.0.17763 x86_64)
[14:10:18] E/launcher - WebDriverError: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
(Driver info: chromedriver=79.0.3945.16 (93fcc21110c10dbbd49bbff8f472335360e31d05-refs/branch-heads/3945#{#262}),platform=Windows NT 10.0.17763 x86_64)
at Object.checkLegacyResponse (C:\Install\node-v12.13.1-win-x64\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\Install\node-v12.13.1-win-x64\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13)
at C:\Install\node-v12.13.1-win-x64\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:441:30
at processTicksAndRejections (internal/process/task_queues.js:93:5)
From: Task: WebDriver.createSession()
at Function.createSession (C:\Install\node-v12.13.1-win-x64\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:769:24)
at Function.createSession (C:\Install\node-v12.13.1-win-x64\node_modules\protractor\node_modules\selenium-webdriver\chrome.js:761:15)
at Direct.getNewDriver (C:\Install\node-v12.13.1-win-x64\node_modules\protractor\built\driverProviders\direct.js:77:33)
at Runner.createBrowser (C:\Install\node-v12.13.1-win-x64\node_modules\protractor\built\runner.js:195:43)
at C:\Install\node-v12.13.1-win-x64\node_modules\protractor\built\runner.js:339:29
at _fulfilled (C:\Install\node-v12.13.1-win-x64\node_modules\protractor\node_modules\q\q.js:834:54)
at C:\Install\node-v12.13.1-win-x64\node_modules\protractor\node_modules\q\q.js:863:30
at Promise.promise.promiseDispatch (C:\Install\node-v12.13.1-win-x64\node_modules\protractor\node_modules\q\q.js:796:13)
at C:\Install\node-v12.13.1-win-x64\node_modules\protractor\node_modules\q\q.js:556:49
at runSingle (C:\Install\node-v12.13.1-win-x64\node_modules\protractor\node_modules\q\q.js:137:13)
[14:10:18] E/launcher - Process exited with error code 199
Config
exports.config = {
chromeOnly: true,
directConnect: true,
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--no-sandbox', "--headless", "--disable-gpu", "--window-size=800,600"]
},
},
specs: ['login.jenkins.js']
};
The reason for this error is that there are multiple chrome browser instances running on different profiles. When protractor starts your tests, chrome creates a default profile and runs your tests on that profile. If there are multiple chrome instances running, chrome will ask for your user defined profile in the --user-data-dir argument.
This means that you should make sure that there are no pending processes of chrome running before you start your tests. Check for running processes and remove those processes. Then make sure you add an onComplete section like below in your configuration file so that your chrome browser instance is closed after your tests are done. Here is the code snippet.
onComplete: async () => {
await browser.driver.close();
await browser.driver.quit();
}
Try it out once! Might solve the problem you are facing.

This version of ChromeDriver has not been tested with Chrome version 79 error running protractorE2E tests with ChromeDriver Chrome Selenium

Those are my settings:
.gitlab-ci.yml
image: node
stages:
- test
tests:
stage: test
before_script:
# Add Google Chrome to aptitude's (package manager) sources
- echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | tee -a /etc/apt/sources.list
# Fetch Chrome's PGP keys for secure installation
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
# Update aptitude's package sources
- apt-get -qq update -y
# Install latest Chrome stable, Xvfb packages
- apt-get -qq install -y google-chrome-stable xvfb gtk2-engines-pixbuf xfonts-cyrillic xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable imagemagick x11-apps default-jre
# Launch Xvfb
- Xvfb :0 -ac -screen 0 1024x768x24 &
# Export display for Chrome
- export DISPLAY=:99
# Install AngularJS CLI exclusively
# Add --unsafe-perm to resolve problems with node-gyp infinite loop on Docker
- npm install --silent --unsafe-perm -g #angular/cli#1.1.2
script:
- npm i --quiet
- npm run wd-update
- npm run wd-start &
- npm run start -- js-files/psh.conf.js
- npm run wd-shutdown
only:
- master
- merge_request
And this is the job outoput for tests
Running with gitlab-runner 12.3.0 (a8a019e0)
on runner-gitlab-runner-554cdd7fbc-4t8mw zxqBkdf4
Using Kubernetes namespace: gitlab-managed-apps
Using Kubernetes executor with image node ...
Waiting for pod gitlab-managed-apps/runner-zxqbkdf4-project-62-concurrent-15jnmx to be running, status is Pending
Running on runner-zxqbkdf4-project-62-concurrent-15jnmx via runner-
$ npm i --quiet
> canvas#2.6.0 install /builds/automation/bender/node_modules/canvas
> node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using request for node-pre-gyp https download
[canvas] Success: "/builds/automation/bender/node_modules/canvas/build/Release/canvas.node" is installed via remote
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#2.1.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
added 457 packages from 433 contributors and audited 1390 packages in 15.657s
found 0 vulnerabilities
$ npm run wd-update
> bender#1.0.0 wd-update /builds/automation/bender
> webdriver-manager update
[15:03:41] I/file_manager - creating folder /builds/automation/bender/node_modules/protractor/node_modules/webdriver-manager/selenium
[15:03:41] I/config_source - curl -o/builds/automation/bender/node_modules/protractor/node_modules/webdriver-manager/selenium/standalone-response.xml https://selenium-release.storage.googleapis.com/
[15:03:41] I/config_source - curl -o/builds/automation/bender/node_modules/protractor/node_modules/webdriver-manager/selenium/chrome-response.xml https://chromedriver.storage.googleapis.com/
[15:03:41] I/config_source - curl -o/builds/automation/bender/node_modules/protractor/node_modules/webdriver-manager/selenium/gecko-response.json https://api.github.com/repos/mozilla/geckodriver/releases
[15:03:42] I/downloader - curl -o/builds/automation/bender/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_78.0.3904.105.zip https://chromedriver.storage.googleapis.com/78.0.3904.70/chromedriver_linux64.zip
[15:03:42] I/downloader - curl -o/builds/automation/bender/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.141.59.jar https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar
[15:03:42] I/update - chromedriver: unzipping chromedriver_78.0.3904.105.zip
[15:03:42] I/update - chromedriver: setting permissions to 0755 for /builds/automation/bender/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_78.0.3904.105
[15:03:42] I/downloader - curl -o/builds/automation/bender/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.26.0.tar.gz https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz
[15:03:43] I/update - geckodriver: unzipping geckodriver-v0.26.0.tar.gz
[15:03:43] I/update - geckodriver: setting permissions to 0755 for /builds/automation/bender/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.26.0
$ npm run wd-start &
$ npm run start -- js-files/psh.conf.js
> bender#1.0.0 wd-start /builds/automation/bender
> webdriver-manager start
> bender#1.0.0 prestart /builds/automation/bender
> tsc && ts-cleaner -d js-files
[15:03:44] I/start - java -Djava.security.egd=file:///dev/./urandom -Dwebdriver.gecko.driver=/builds/automation/bender/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.26.0 -Dwebdriver.chrome.driver=/builds/automation/bender/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_78.0.3904.105 -jar /builds/automation/bender/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.141.59.jar -port 4444
[15:03:44] I/start - seleniumProcess.pid: 15684
15:03:45.253 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
15:03:45.506 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2019-12-17 15:03:45.713:INFO::main: Logging initialized #1029ms to org.seleniumhq.jetty9.util.log.StdErrLog
15:03:46.441 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
15:03:46.780 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
> bender#1.0.0 start /builds/automation/bender
> node src/flake "js-files/psh.conf.js"
[15:03:52] I/launcher - Running 1 instances of WebDriver
[15:03:52] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
15:03:52.446 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"chromeOptions": {
"args": [
"--headless",
"--no-sandbox",
"--window-size=1550,768"
]
},
"count": 1,
"maxInstances": 1,
"shardTestFiles": false
}
15:03:52.449 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 78.0.3904.70 (edb9c9f3de0247fd912a77b7f6cae7447f6d3ad5-refs/branch-heads/3904#{#800}) on port 3722
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1576595032.499][SEVERE]: bind() failed: Cannot assign requested address (99)
[1576595033.109][WARNING]: This version of ChromeDriver has not been tested with Chrome version 79.
15:03:53.266 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C
15:03:53.323 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 26b7b655c1318cbcde9cfb69871f56ad (org.openqa.selenium.chrome.ChromeDriverService)
(node:15719) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Started
Jasmine started
2019-12-17T15:03:53.447Z - info: Current test running:
Psh site validations Site language should change
(node:15719) UnhandledPromiseRejectionWarning: WebDriverError: invalid session id
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'runner-zxqbkdf4-project-62-concurrent-15jnmx', ip: '10.36.0.39', os.name: 'Linux', os.arch: 'amd64', os.version: '4.14.138+', java.version: '1.8.0_232'
Driver info: driver.version: unknown
at Object.checkLegacyResponse (/builds/automation/bender/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/builds/automation/bender/node_modules/selenium-webdriver/lib/http.js:509:13)
at /builds/automation/bender/node_modules/selenium-webdriver/lib/http.js:441:30
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:15719) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:15719) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:15719) UnhandledPromiseRejectionWarning: WebDriverError: invalid session id
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'runner-zxqbkdf4-project-62-concurrent-15jnmx', ip: '10.36.0.39', os.name: 'Linux', os.arch: 'amd64', os.version: '4.14.138+', java.version: '1.8.0_232'
Driver info: driver.version: unknown
at Object.checkLegacyResponse (/builds/automation/bender/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/builds/automation/bender/node_modules/selenium-webdriver/lib/http.js:509:13)
at /builds/automation/bender/node_modules/selenium-webdriver/lib/http.js:441:30
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:15719) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:15719) UnhandledPromiseRejectionWarning: WebDriverError: invalid session id
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'runner-zxqbkdf4-project-62-concurrent-15jnmx', ip: '10.36.0.39', os.name: 'Linux', os.arch: 'amd64', os.version: '4.14.138+', java.version: '1.8.0_232'
Driver info: driver.version: unknown
at Object.checkLegacyResponse (/builds/automation/bender/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/builds/automation/bender/node_modules/selenium-webdriver/lib/http.js:509:13)
at /builds/automation/bender/node_modules/selenium-webdriver/lib/http.js:441:30
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:15719) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
So, the error that I having is:
UnhandledPromiseRejectionWarning: WebDriverError: invalid session id
Any idea about this?
I was researching about two days at least and I didn't found anything related, I see a lot of errors but no one like this.
Should I use a docker image? instead install everything on the fly?
I couldn't find a docker image that match with my necessity.
Is the seleniumaddress that I'm using correct?
It's the one recommended by protractor site: seleniumAddress: 'http://localhost:4444/wd/hub'
This error message...
Starting ChromeDriver 78.0.3904.70
.
[1576595033.109][WARNING]: This version of ChromeDriver has not been tested with Chrome version 79.
.
15:03:53.323 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 26b7b655c1318cbcde9cfb69871f56ad (org.openqa.selenium.chrome.ChromeDriverService)
(node:15719) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=78.0
Release Notes of chromedriver=78.0 clearly mentions the following :
Supports Chrome version 78
You are using chrome= 79.0
Release Notes of ChromeDriver v79.0 clearly mentions the following :
Supports Chrome version 79
So there is a clear mismatch between the ChromeDriver v78.0 and the Chrome Browser v79.0
Solution
Ensure that:
ChromeDriver is updated to current ChromeDriver v79.0 level.
Chrome is updated to current Chrome Version 79.0 level. (as per ChromeDriver v79.0 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Reference
You can find a relevant detailed discussion in:
How to work with a specific version of ChromeDriver while Chrome Browser gets updated automatically through Python selenium
If you are using npm implementation of protractor type below command in cmd . Today by chrome version was changed to 79 and doing this solved my issue .
webdriver-manager update

session not created: Chrome version must be between 71 and 75 [duplicate]

After update of chromedriver to version 2.46 my tasts fail to initialize.
I got message like this:
Starting ChromeDriver 2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1) on port 44269
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Failed to invoke configuration method com.personal.CustomTest.initTests not created: Chrome version must be between 71 and 75
(Driver info: chromedriver=2.46.628402,platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.58 seconds
Build info: version: '2.53.1'
It is clearly saying that my browser version is not valid. But I am using Chrome 72.0.3626.119 so it is between 71 and 75.
Selenium version is 2.53.1.
And I am running test through console command with the help of testNG.
Any idea? Every ideas that I found was about changing selenium version but I cant do it.
For me to resolve this problem :
On Windows
cd C:\Users\[myname]\AppData\Roaming\npm\node_modules\protractor
npm i webdriver-manager#latest
webdriver-manager update
webdriver-manager start &
On Cent-OS (I used Cent-OS 7.4.* and it worked fine.)
cd /usr/lib/node_modules/protractor/
sudo npm i webdriver-manager#latest
sudo webdriver-manager update
sudo webdriver-manager start &
I hope this helps you in any way.
This error message...
Starting ChromeDriver 2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1) on port 44269
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Failed to invoke configuration method com.personal.CustomTest.initTests not created: Chrome version must be between 71 and 75
...implies that the ChromeDriver v2.46 is not compatible with the Chrome Browser version which is being accessed by your program/webdriver.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.46
Release Notes of chromedriver=2.46 clearly mentions the following :
Supports Chrome v71-73
Though you mentioned you are using Chrome 72.0.3626.119 possibly there are multiple instances of Chrome Browser installed within your system and your program by default is accessing the Chrome Browser whose version is not between v71.x and v75.x
You are using chrome=67.0
Release Notes of ChromeDriver v2.38 clearly mentions the following :
Supports Chrome v65-67
Solution
Keep JDK upgraded to recent levels JDK 8u201.
Uninstall all the instances of Chrome Browser (you can opt to use Revo Uninstaller).
Upgrade ChromeDriver to current ChromeDriver v2.46 level.
Keep Chrome version between Chrome v71-73 levels. (as per ChromeDriver v2.46 release notes)
For me, I had to update my chrome driver in my project to match the version of Chrome on my local machine.
yarn add chromedriver#76.0.0 -D
https://www.npmjs.com/package/chromedriver
In my case I was getting the same error after my chrome was updated to version 76. Which was happening when chimp tries to use chromedriver to execute the selenium test.
DevTools listening on ws://127.0.0.1:49220/devtools/browser/e88586cb-ed67-44fc-a742-43b767e2b8f9
[chimp][helper] setupBrowserAndDDP had error
{ Error: session not created: Chrome version must be between 71 and 75
at Object.wait (C:\ACPMS\ELS_AT\node_modules\fibers\future.js:449:15)
at Object.<anonymous> (C:\ACPMS\ELS_AT\node_modules\wdio-sync\build\index.js:344:27)
at Object.<anonymous> (C:\ACPMS\ELS_AT\node_modules\chimp\dist\lib\session-manager.js:145:21)
at initBrowser (C:\ACPMS\ELS_AT\node_modules\chimp\dist\lib\chimp-helper.js:189:43)
at Object.setupBrowserAndDDP (C:\ACPMS\ELS_AT\node_modules\chimp\dist\lib\chimp-helper.js:264:7)
at Context.<anonymous> (C:\ACPMS\ELS_AT\node_modules\chimp\dist\lib\mocha\mocha-helper.js:13:15)
at C:\ACPMS\ELS_AT\node_modules\chimp\dist\lib\utils\fiberize.js:29:22
(Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17134 x86_64)
at new RuntimeError (C:\ACPMS\ELS_AT\node_modules\webdriverio\build\lib\utils\ErrorHandler.js:143:12)
at Request._callback (C:\ACPMS\ELS_AT\node_modules\webdriverio\build\lib\utils\RequestHandler.js:318:39)
at Request.self.callback (C:\ACPMS\ELS_AT\node_modules\request\request.js:185:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (C:\ACPMS\ELS_AT\node_modules\request\request.js:1161:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous>
For me it didn't work when I updated the chrome driver by npm (both globally and locally) and then I followed these steps to resolve the issue, which might give some idea on where to check in this kind a issue:
Because exception was thrown in node_modules\chimp\dist\lib\utils\fiberize.js i navigated to that file and found one level above this file node_modules\chimp\dist\lib\chromedriver.js which has the code to start chromedriver.
I added a console.log to chromedriverPath which can be seen below and re-executed the tests to get the chromedriver path in console logs.
Chromedriver.prototype.start = function(callback) {
var self = this;
var port = self.options.port;
if (this.child) {
callback();
return;
}
var chromedriverPath = chromedriver.path;
//this was added my me the see that chrome drive path
console.log("[chimp] " + chromedriverPath);
if (fs.existsSync(chromedriverPath)) {
this.child = processHelper.start(
{
bin: chromedriverPath,
prefix: "chromedriver",
args: ["--port=" + port, "--url-base=wd/hub"],
waitForMessage: /Starting ChromeDriver/,
errorMessage: /Error/
},
callback
);
} else {
callback("[chimp][chromedriver] Chromedriver executable not found.");
}
};
When i got the path of the chromedriver which is used to execute the tests, i just navigated to that folder and replaced chromedriver executable with the most recent version.
I hope this helps.
Try this: Download the compatible ChromeDriver.exe file for the updated version of Chrome browser and replace it. It works for me.

e2e tests fail on server with selenium

I'm about to create an application full js based on vuejs. Following https://github.com/vuejs-templates/webpack, I have started a project:
$ vue init webpack my-project && cd my-project && yarn install
When I run unittest yarn run unit everything goes well, but when I run yarn run e2e which runs nightwatch.js, I get this error:
> Starting dev server...
Starting to optimize CSS...
> Listening at http://localhost:8889
Starting selenium server... started - PID: 23451
started - PID: 23451
[Test] Test Suite
=====================
Running: default e2e tests
[client :: capabilities] Test Suite
=======================================
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ Error: socket hang up
at createHangUpError (_http_client.js:344:15)
at Socket.socketOnEnd (_http_client.js:436:23)
at emitNone (events.js:110:20)
at Socket.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1047:12)
at _combinedTickCallback (internal/process/next_tick.js:102:11)
at process._tickCallback (internal/process/next_tick.js:161:9) code: 'ECONNRESET' }
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The selenium server is started on the fly when the e2e tests start and is shutdown when they finish. I'm sure because when I stop nightwatch.js before it fails I see :
$ ps aux | grep -i selenium
java -Dwebdriver.chrome.driver=node_modules/chromedriver/lib/chromedriver/chromedriver -jar node_modules/selenium-server/lib/runner/selenium-server-standalone-2.53.1.jar -port 4444
So the real error based on the output I get is mostlikely Error retrieving a new session from the selenium server. How do I fix this?
package.json
"chromedriver": "^2.27.2",
"cross-spawn": "^5.0.1",
"nightwatch": "^0.9.12",
"selenium-server": "^2.53.1",
test/e2e/nightwatch.conf.js
require('babel-register')
var config = require('../../config')
// http://nightwatchjs.org/gettingstarted#settings-file
module.exports = {
src_folders: ['test/e2e/specs'],
output_folder: 'test/e2e/reports',
custom_assertions_path: ['test/e2e/custom-assertions'],
selenium: {
start_process: true,
server_path: require('selenium-server').path,
host: '127.0.0.1',
port: 4444,
cli_args: {
'webdriver.chrome.driver': require('chromedriver').path
}
},
I recently started a Vue.js project with Webpack template. Your problem sounds familiar, but surprisingly, I forgot how I solved it...
The only difference I can see between your package.json and mine is the selenium-server version (^3.0.1). You should also check your Node version because Nightwatch is based on it. I remember that I had to update Node and npm for some reason (I do not use Yarn).
This is my environment (and it is working fine):
Node.js (v8.1.3)
npm (5.0.3)
Did you run node nightwatch.config.js, or node {whatever your nightwatch config file is called}. This will install Selenium and ChromeDriver correctly.

NightWatch Selenium Socket Hangup in Jenkins / Ubuntu16

Issue :
We are running NightWatch tests in Jenkins, and once in a while, we get this error :
[0;31mConnection refused! Is selenium server started?
[0m[0;90m{ Error: socket hang up
at createHangUpError (_http_client.js:253:15)
at Socket.socketCloseListener (_http_client.js:285:23)
at emitOne (events.js:101:20)
at Socket.emit (events.js:188:7)
at TCP._handle.close [as _onclose] (net.js:501:12) code: 'ECONNRESET' }[0m
The fix recommended in other places is already there :
export DBUS_SESSION_BUS_ADDRESS=/dev/null
This is how we run the tests :
sudo npm install selenium-standalone -g
selenium-standalone install --version=3.0.1 --baseURL=https://selenium-release.storage.googleapis.com --drivers.chrome.version=2.28 --drivers.chrome.baseURL=https://chromedriver.storage.googleapis.com --basePath=bin
sudo npm install nightwatch#0.9.13 -g && nightwatch --tag sanity --retries 1 --suiteRetries 1
Rebuilding the job usually run the tests successfully.
Softwares' version:
Chrome : 57
Chrome driver : 2.28
Selenium: 3.0.1
NightWatch : 0.9.13 (bumped down from 0.9.14 in case the latest release had a bug but no change.)
Jenkins : 1.6x
Ubuntu : 16.04
Using xvfb
Error Scenarios
The tests were running fine until about 2 weeks ago, just when we switched to Ubuntu 16, but that day it started happening on Ubuntu 14 too.
It especially happens when we've just spun a new Jenkins slave (on AWS cloud.) Happens more often at the very start of the test run but sometimes it happens in the middle of the run too.
I'll appreciate any help or pointers!
I have the same problem yesterday.
Maybe you can change the version of Chrome.
such as Chrome:55.
when i changed the version of chrome the selenium
We ran into a similar issue, but our error message was more specific:
Selenium is already running on port ####. Or some other service is.
The solution was to use the Jenkins Port Allocator Plugin to assign an available port number to an environment variable.
From there, we were able to set the port number in our globals.js like this (with a default of 4444 for running locally):
portNumber: process.env.PORT_NUMBER || 4444,
In our nightwatch.conf.js file, we used a lodash template to replace values in our nightwatch.json like this:
fs = require('fs'),
_ = require('lodash'),
template = _.template(fs.readFileSync('./nightwatch.json', 'utf8')),
settingsString,
settings;
settingsString = template({
portNumber: globals.portNumber
});
settings = JSON.parse(settingsString);
module.exports = settings;
Finally, in our nightwatch.conf file, we set the values for all port references to:
"<%= portNumber %>"