1
votes

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.

2
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

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 conf.js file

My script.sh to trigger protractor test from Jenkins

New script.sh file enter image description here

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