Configure saucelabs for jenkins

2019-05-30 15:06发布

问题:

I am trying to run my protractor tests on my Jenkins server which happens to be a Linux box (Red Hat Enterprise Linux Server release 6.6) which has no browser. So i did some research and realized I would have to use saucelabs. I do have saucelab account. So i was confused on how to edit my conf.js file and also how i will communicate with saucelabs from my box.

This is my current conf.js file

var HtmlReporter = require('protractor-html-screenshot-reporter');

var reporter=new HtmlReporter({
    baseDirectory: './result', 
    docTitle: Result',
    docName:    'report.html'
});

exports.config = {

  seleniumAddress: 'http://localhost:4444/wd/hub',

  specs: ['spec.js'],

  onPrepare: function() {
        jasmine.getEnv().addReporter(reporter);
    },

  capabilities: {
    browserName: 'chrome'
  }
}

My understanding is I have to add my username and access key for saucelabs as such

export SAUCE_USERNAME=YOUR_USERNAME

export SAUCE_ACCESS_KEY=YOUR_ACCESS_KEY

I was wondering how exactly it will go in my conf.js file and also MOST IMPORTANT, HOW will my linux box be communicating with sauce labs???? Please advice

回答1:

Here is an example config protractor provides to help you run your tests on Saucelabs.

Most importantly, you need to specify the sauceUser and sauceKey to make it work:

exports.config = {
  sauceUser: "user",
  sauceKey: "key",

  // ...

}