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.
1
votes
2 Answers
3
votes
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.
1
votes
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