bitecoder
bitecoder

Reputation: 55

How to setup and run angular js protractor test in jenkins?

I have following configuration but getting error

ERROR

registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match the current platform LINUX
18:17:05.892 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{platform=WINDOWS, browserName=MicrosoftEdge, version=}] does not match the current platform LINUX
18:17:05.896 INFO - Driver class not found: com.opera.core.systems.OperaDriver
18:17:05.896 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
18:17:06.187 WARN - Failed to start: [email protected]:4444
Exception in thread "main" java.net.BindException: Selenium is already running on port 4444. Or some other service is.
    at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:492)
    at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:305)
    at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:245)
    at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:64)
Selenium Standalone has exited with code 1
Selenium standalone server started at http://10.33.24.128:43448/wd/hub

Jenkins commands

## run testing
node_modules/protractor/bin/webdriver-manager update --standalone
node_modules/protractor/bin/webdriver-manager start > /dev/null 2>&1 &

while ! curl http://localhost:4444/wd/hub/status &>/dev/null; do :; done

node_modules/protractor/bin/protractor protractor.conf.js

My configuration file is below

exports.config = {
  directConnect: false,

  capabilities: {
    'browserName': 'chrome'
  },
    chromeDriver: './node_modules/protractor/selenium/chromedriver',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  framework: 'jasmine',
  specs: ['tests/specs/*-spec.js'],
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000
  }
};

Upvotes: 1

Views: 1404

Answers (2)

Vishal Aggarwal
Vishal Aggarwal

Reputation: 4239

Avoid handling directly this and delegate it to gulp plugin like gulp-angular-protractor to:

1).Start/stop selenium server

2).And run protractor tests

Full Example

Gulpfile.js

/*jshint node: true, camelcase: false*/
/*global require: true*/

'use strict';

var gulp = require('gulp'),
gulpProtractorAngular = require('gulp-angular-protractor');

// Setting up the test task
gulp.task('regression-suite', function(callback) {
    gulp
        .src(['./tests/specs/*spec.js'])
        .pipe(gulpProtractorAngular({
            'configFile': 'protractor.conf.js',
            'debug': false,
            'autoStartStopServer': true
        }))
        .on('error', function(e) {
            console.log(e);
        })
        .on('end', callback);
});

conf.js

Same as before

Command Prompt

C:>gulp regression-suite

Jenkins

Add a step as execute windows command

gulp regression-suite

Upvotes: 0

Christopher Orr
Christopher Orr

Reputation: 111623

You have an error message:

Selenium is already running on port 4444. Or some other service is.

So your tests are failing because Selenium could not be set up, as the port it requires is already in use.

This could be perhaps because another build running in parallel on the same machine, or because Selenium wasn't stopped by a previous build, or some other server is using port 4444.

You need to ensure that this port is free before starting your build.

You can restrict multiple builds running in parallel on the same machine that want to use the same port number with the Port Allocator plugin or the Throttle Concurrent Builds plugin.

Upvotes: 0

Related Questions