Search code examples
jenkinsangularprotractor

Protractor does not runnnig correctly as Jenkins Job


I'm trying to run my Protractor test on a Jenkins server. But I get every time following error message:

TypeError: Cannot read property 'visibilityOf' of undefined

Stacktrace: TypeError: Cannot read property 'visibilityOf' of undefined at waitingForElement (/var/lib/jenkins/jobs/workspace/project/dist/dev/scripts/test/e2e/helper.e2e.js:9:20) at Object.switchTab (/var/lib/jenkins/jobs/workspace/project/dist/dev/scripts/test/e2e/helper.e2e.js:135:5) at null. (/var/lib/jenkins/jobs/workspace/project/dist/dev/scripts/test/e2e/test-employee.e2e.js:87

This is the respective code:

function waitingForElement(elem, timeOut) { 
    var EC = protractor.ExpectedConditions;
    browser.wait(EC.visibilityOf(elem), timeOut);
    ....    
}

And at the top line line I have a reference to the angular-protractor typings:

/// <reference path="../../../../typings_custom/angular-protractor/index.d.ts" />

And this is my Jenkins configuration:

echo "build tests"
npm run build.e2e   
#Run protractor
protractor protractor-config.js --params.url "http://localhost:90" --suite testSuite

But when I'm runnig the Protractor test locally or in a server terminal then they are working, but not as Jenkins job.

Any ideas?


Solution

  • The error results in missing rights to execute the global protractor installation.

    The solution is quite simple, I need to use the local "installation" of protractor: ./node_modules/protractor/bin/protractor ...