Error while executing an automated script from azure pipeline - azure

We have a script which was written in Protractor using node.js and grunt.
We have built an azure pipeline to execute that automated script by fetching it from github. Please see the commands we have written in yml file.
pool:
vmImage: 'vs2017-win2016'
steps:
- task: NodeTool#0
inputs:
versionSpec: '8.x'
displayName: 'Install Node.js'
- script: |
node --version
npm install
npm install -g grunt-cli
npm install grunt-cli
npm install grunt --save-dev
displayName: 'npm install and run grunt'
- script: |
npm install webdriver-manager -g
npm install protractor -g
webdriver-manager update
webdriver-manager start
displayName: 'Webdriver install'
- task: CmdLine#2
inputs:
script: |
cd resources
grunt
Question1: The script executes in 5 mins whereas with azure pipeline it takes 15 to 20 mins to run. Is it really worth to install all packages everytime and execute script through azure.
Question2: the command webdriver-manager start is a mandatory step for execution of the script(This is to make the selenium hub up and running), but while running the yml file, this particular step is throwing error and gets skipped.
Please see the error below.
[12:36:53] I/launcher - Running 1 instances of WebDriver
2018-12-18T12:36:53.4831548Z [12:36:53] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
2018-12-18T12:36:54.2436510Z [12:36:54] E/launcher - Error code: 135
2018-12-18T12:36:54.2436720Z [12:36:54] E/launcher - Error message: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
2018-12-18T12:36:54.2436826Z [12:36:54] E/launcher - Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
2018-12-18T12:36:54.2441705Z [12:36:54] E/launcher - Process exited with error code 135
2018-12-18T12:36:54.2532843Z ‌>> ‌
2018-12-18T12:36:54.2537675Z ‌Warning: Tests failed, protractor exited with code: 135 Use --force to continue.‌
2018-12-18T12:36:54.2608988Z
2018-12-18T12:36:54.2609215Z ‌Aborted due to warnings.‌
2018-12-18T12:36:54.3660216Z ##[error]Cmd.exe exited with code '135'.
We have tried another way to execute the script, by hardcoding the selenium hub address in config.js (instead of localhost, ip address is provided) like this
seleniumAddress: 'http://<ipaddress>:4444/wd/hub',
but we see a different error as shown below.
2018-12-18T12:23:06.4867590Z ‌Running "protractor:e2e_tests" (protractor) task‌
2018-12-18T12:23:07.0061140Z I/launcher - Running 1 instances of WebDriver
2018-12-18T12:23:07.0061367Z I/hosted - Using the selenium server at http://:4444/wd/hub
2018-12-18T12:23:28.0555423Z E/launcher - ETIMEDOUT connect ETIMEDOUT :4444
2018-12-18T12:23:28.0556179Z E/launcher - Error: ETIMEDOUT connect ETIMEDOUT :4444
2018-12-18T12:23:28.0571368Z E/launcher - Process exited with error code 199
2018-12-18T12:23:28.0635055Z ‌>> ‌
2018-12-18T12:23:28.0635654Z ‌Warning: Tests failed, protractor exited with code: 199 Use --force to continue.‌
2018-12-18T12:23:28.0668847Z
2018-12-18T12:23:28.0688725Z ‌Aborted due to warnings.‌
2018-12-18T12:23:28.1695155Z ##[error]Cmd.exe exited with code '199'.
Any help will be highly appreciated. Thanks in advance!!

Related

Unable to start Selenium server due to error "UNABLE_TO_GET_ISSUER_CERT_LOCALLY"

I have uninstalled/reinstalled nodejs, protractor, selenium, webdriver-manager but error continues.
- What else should I uninstall or update?
- Can someone please provide next steps or some direction to correct issue?
- where do i get the local certificate?
my commands:
1. webdriver-manager update --ignore_ssl --proxy http://password#proxy.path.com:8080
2. webdriver-managerstart ---(error details below)
Current global installed versions:
protractor Version 5.4.3
webdriver-manager 12.1.7
selenium standalone version available: 3.141.59
chromedriver version available: 80.0.3987.106
geckodriver version available: v0.26.0
Error: unable to get local issuer certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1473:34)
at TLSSocket.emit (events.js:311:20)
at TLSSocket._finishInit (_tls_wrap.js:916:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:686:12) {
code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY'
}
[13:56:46] I/start - java -Dwebdriver.gecko.driver=C:\Users\USERNAME\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\geckodriver-v0.26.0.exe -jar C:\Users\USERNAME\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.141.59.jar -port 4444
[13:56:46] I/start - seleniumProcess.pid: 2884
13:56:46.834 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
13:56:46.957 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2020-03-17 13:56:47.035:INFO::main: Logging initialized #513ms to org.seleniumhq.jetty9.util.log.StdErrLog
13:56:47.373 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
13:56:48.375 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
Can you run the webdriver-manager update --ignore_ssl from your local project node modules, probably your command is running globally, Try the below options , either one should work
Run ./node_modules/webdriver-manager update --ignore_ssl --proxy with proxy
Run ./node_modules/webdriver-manager update --ignore_ssl without proxy
"Run ./node_modules/webdriver-manager update --ignore_ssl --proxy with proxy"
I ran suggestion above but get this error message with business proxy:
I/http_utils - ignoring SSL certificate
E/downloader - Expected response code 200, received: 403
I/update - selenium standalone: file exists .AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.141.59.jar
I/update - selenium standalone: selenium-server-standalone-3.141.59.jar up to date
(node:72544) UnhandledPromiseRejectionWarning: Error: response status code is not 200

Server terminated early with status 2 error while running e2e tests on windows

I'm working on an angular 2 app and for that I've configured protractor for end-2-end testing. but when I try to run the test cases, I get the following error
[11:53:45] I/local - Starting selenium standalone server...
[11:53:45] I/launcher - Running 1 instances of WebDriver
[11:53:45] E/launcher - Server terminated early with status 2
[11:53:45] E/launcher - Error: Server terminated early with status 2
at Error (native)
at C:\Users\Dell\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\remote\index.js:242:20
at ManagedPromise.invokeCallback_ (C:\Users\Dell\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1379:14)
at TaskQueue.execute_ (C:\Users\Dell\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14)
at TaskQueue.executeNext_ (C:\Users\Dell\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2896:21)
at asyncRun (C:\Users\Dell\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2775:27)
at C:\Users\Dell\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:639:7
at process._tickCallback (internal/process/next_tick.js:109:7)
[11:53:45] E/launcher - Process exited with error code 199
webdriver-manager version: 10.3.0
node version: 6.11.0
npm version: 3.8.6
protractor version: 4.0.9
Environment: Windows
I've searched the web but unable to find solution for the issue. Any help would be appreciated. Thanks

How can I use saucelabs connect with circle-ci 2.0?

In circle-ci 1.0 the config file seemed to specify dependencies. I noticed that in circle-ci 2.0 that this concept is gone to some degree.
Sooo I tried the following:
steps:
- checkout
- run:
name: Install Sauce Connect
command: |
wget https://saucelabs.com/downloads/sc-latest-linux.tar.gz
tar -xzf sc-latest-linux.tar.gz
...
- run: yarn integration
Seems like this didn't quite pan out. I get the following result in circle-ci's console:
#!/bin/bash -eo pipefail
yarn run integration
yarn run v0.24.6
$ node_modules/.bin/wdio test/wdio.conf.js
A service failed in the 'onPrepare' hook
Error: Could not start Sauce Connect. Exit code 1 signal: null
at ChildProcess.<anonymous> (/home/circleci/repo/node_modules/sauce-connect-launcher/lib/sauce-connect-launcher.js:559:12)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
Continue...
ERROR: connect ECONNREFUSED 127.0.0.1:4445
chrome
Error
ERROR: connect ECONNREFUSED 127.0.0.1:4445
chrome
Error
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Exited with code 1
I'm using wdio, with the sauce and mocha plugins. It works locally. Ideas? Any guides that exist anywhere for this? Google didn't produce any answers for circle-ci 2.0 and saucelabs integrations.

Protractor for NodeJS on a virtual machine - How do I fix error 199?

I'm trying to use Protractor on a virtual machine and am getting the error code 199.
I am following this tutorial with the exact same steps - http://www.protractortest.org/#/tutorial
When I enter protractor conf.js on the command line, I get the following error:
[14:51:31] I/hosted - Using the selenium server at (my url here)
[14:51:31] I/launcher - Running 1 instances of WebDriver
[14:51:51] E/launcher - null
[14:51:51] E/launcher - WebDriverError: null
at WebDriverError (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:27:5)
at Object.checkLegacyResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:639:15)
at parseHttpResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:538:13)
at client_.send.then.response (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:472:11)
at ManagedPromise.invokeCallback_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1379:14)
at TaskQueue.execute_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at asyncRun (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2820:25)
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
at Function.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:329:24)
at Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/builder.js:458:24)
at Hosted.DriverProvider.getNewDriver (/usr/local/lib/node_modules/protractor/built/driverProviders/driverProvider.js:37:33)
at Runner.createBrowser (/usr/local/lib/node_modules/protractor/built/runner.js:197:43)
at /usr/local/lib/node_modules/protractor/built/runner.js:276:30
at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:796:13)
at /usr/local/lib/node_modules/protractor/node_modules/q/q.js:556:49
at runSingle (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:137:13)
[14:51:51] E/launcher - Process exited with error code 199
The problem is not connecting to the webdriver as I have exposed a port and able to access the url and view the hub for it.
Thanks.
After a lot of prodding, running strace, running manually etc I managed to get to the bottom of this on debian/devuan. If I ran chromium by hand it worked fine (Chrome would appear and I could browse). However every time I ran protractor there would a long hang followed by:
E/launcher - null
E/launcher - WebDriverError: null
strace of protractor was showing selenium was returning a 500 series error. Looking at ps uwww allowed me to see that the following command was being executed:
java -Dwebdriver.chrome.driver=.../webdriver-manager/selenium/chromedriver_2.26
-jar .../selenium-server-standalone-2.53.1.jar -port 60987
Running this manually, connecting to the instance, creating a new session and selecting chrome gave the error:
.../webdriver-manager/selenium/chromedriver_2.26: error while loading shared libraries:
libgconf-2.so.4: cannot open shared object file: No such file or directory
On installing libgconf2 with apt-get install libgconf-2-4 (on Devuan Jessie) this then fixed both the manually created selenium instance and the protractor test.

Chromedriver works manually but fails when ran from Jenkins Slave

I have a Jenkins slave node setup with LinuxMint. So we can do some browser testing on a Linux box in Chrome and Firefox.
I have the latest Chromedriver installed where the test can run it and when I go into /var/jenkins/workspace/<project name>/TestAutomation/SeleniumFramework manually and do my run npm <test name> the tests launch the chromedriver and run successfully.
When I go into Jenkins and run my test chromedriver is failing with the following and I am not sure where to go with this.:
Using ChromeDriver directly...
[launcher] Running 1 instances of WebDriver
/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/atoms/error.js:108
var template = new Error(this.message);
^
UnknownError: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.21.371461 (633e689b520b25f3e264a2ede6b74ccc23cb636a),platform=Linux 3.19.0-32-generic x86_64)
at new bot.Error (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/atoms/error.js:108:18)
at Object.bot.response.checkResponse (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/atoms/response.js:109:9)
at /var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:160:24
at promise.ControlFlow.runInFrame_ (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1857:20)
at goog.defineClass.notify (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2448:25)
at promise.Promise.notify_ (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:564:12)
at Array.forEach (native)
at promise.Promise.notifyAll_ (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:553:15)
at goog.async.run.processWorkQueue (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/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_ (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)
at Function.webdriver.WebDriver.createSession (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)
at new Driver (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/chrome.js:810:36)
at DirectDriverProvider.getNewDriver (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/protractor/lib/driverProviders/direct.js:68:16)
at Runner.createBrowser (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/protractor/lib/runner.js:182:37)
at /var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/protractor/lib/runner.js:263:21
at _fulfilled (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/q/q.js:759:13)
at /var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/q/q.js:525:49
[launcher] Process exited with error code 1
First Solution:
Have you java 8 installed? If yes, uninstall it and install java 7.
Second Solution:
Downgrade protractor to v1.8.0
~
More informations: https://github.com/angular/protractor/issues/1905
#edit
I found a similar topic as your, the same error in jenkins - linux:
In you jenkins settings add a global property
key : DISPLAY
value:0:0
On your server start Xvfb in the background:
Xvfb :0 -ac -screen 0 1024x768x24 &
link: unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.9
So I was connecting to the slaves from the Jenkins master via SSH. This wasn't ever going to launch a browser session. I switched over to the Java Web Start option, and it launched the browser just fine.

Resources