I have used phantomjs but compatibility of phantom js is bad with protractor. Though in chrome and firefox browser I am able to find elements but same locators are not found in phantomjs.
Asked
Active
Viewed 3,025 times
-1
-
You need to narrow your question down. Is Jenkins on Linux? Do you have access to a Windows slave that can run the tests for you? Does the Jenkins box have a GUI part? Jenkins will run Chrome just fine, if it is installed on that system. – PeterS Aug 23 '16 at 11:17
2 Answers
3
If you are using linux OS then you can use xvfb
to launch the chrome browser in headless mode.
To install xvfb, run the below commands in terminal
sudo apt-get update
sudo apt-get install -y xvfb
Once you install xfvb, you can run your protractor scripts using the below command,
xvfb-run protractor configuration.js
The above command will start your chrome browser in headless mode and will execute all specs mentioned in the configuration.js file.

Sudharsan Selvaraj
- 4,792
- 3
- 14
- 22
-
Thank you Sudharasan ffor your quick reply. Now I am facing below issue: [launcher] Process exited with error code 1 /var/lib/jenkins/workspace/media-msod-automationtest-master/node_modules/protractor/node_modules/q/q.js:155 throw e; ^ SyntaxError: Unexpected token ) at goog.loadModuleFromSource_ (/var/lib/jenkins/workspace/media-msod-automationtest- – subhasish Aug 26 '16 at 15:11
-
-
are you facing the same issue when you run protractor without xvfb-rub? – Sudharsan Selvaraj Aug 26 '16 at 15:16
-
No It works fine when I run without xvfb-run in my local. But When I am trying to run with xvfb in Jenkin, I am getting above error. – subhasish Aug 26 '16 at 16:59
-
Which os are you using and have you tried running the xvfb-run in terminal directly? – Sudharsan Selvaraj Aug 26 '16 at 17:02
-
Below i have added my conf.js , package json, scripts which i am using to run protractor from Jenkin and error which i am getting from Jenkin. Please have a look and help – subhasish Aug 26 '16 at 17:17
-
I am using Ubuntu. I am getting an error as 'xvfb-run error xvfb failed to start' . i have added a new script.sh file. plz have a look and help. – subhasish Sep 01 '16 at 05:32
1
My Package.JSON:
{
"name": "Protractor-Test",
"version": "1.0.0",
"description": "UI Automation of Media WorkFlow by Protractor",
"main": "conf.js",
"author": "Subhasish Mishra",
"license": "ISC",
"repository": {
"type": "git",
"url": ""
},
"devDependencies": {
"gulp": "^3.9.1",
"jasmine-core": "~2.4.1",
"jasmine-expect": "~2.0.1",
"jasmine-reporters": "~2.1.1",
"karma-junit-reporter": "^0.2.2",
"protractor": "~3.1.1",
"protractor-console": "~2.0.1",
"protractor-html-screenshot-reporter": "0.0.21",
"protractor-jasmine2-html-reporter": "0.0.6",
"selenium-webdriver": "~2.53.2",
"webdriver-manager":"10.2.1"
}
}
My script.sh
to trigger protractor test from Jenkins
New script.sh
file
Error after build from Jenkins
[launcher] Process exited with error code 1
/var/lib/jenkins/workspace/media-msod-automationtest-master/node_modules/protractor/node_modules/q/q.js:155
throw e;
^
SyntaxError: Unexpected token )
at goog.loadModuleFromSource_ (/var/lib/jenkins/workspace/media-msod-automationtest-master/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1123:19)
at Object.goog.loadModule (/var/lib/jenkins/workspace/media-msod-automationtest-master/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1085:46)
at /var/lib/jenkins/workspace/media-msod-a

Daniel Gray
- 1,697
- 1
- 21
- 41

subhasish
- 21
- 1
- 4
-
which version of nodejs are you using in your jenkins server machine? please look at this link. http://stackoverflow.com/questions/33818869/protactor-error-unexpected-token – Sudharsan Selvaraj Sep 01 '16 at 05:52