fypnlp
fypnlp

Reputation: 1545

Keep getting an Error when setting up onPrepare in Protractor configuration file

I am creating my first protractor framework and I am setting up my on prepare in my configuration file.

I keep getting an error X symbol and I can't figure out why.

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',


  specs: ['PageObjectLocator1.js'],

  capabilities: {
    browserName: 'chrome'
  }

  onPrepare = function {

    //place global functions here

  }


}

Here's a screen shot too.

enter image description here

Upvotes: 0

Views: 128

Answers (2)

LazioTibijczyk
LazioTibijczyk

Reputation: 1957

onPrepare should look like this

onPrepare: function() {
   //your code
}

and in your case

exports.config = {
   seleniumAddress: 'http://localhost:4444/wd/hub',
   specs: ['PageObjectLocator1.js'],
   capabilities: { browserName: 'chrome' },  //don't forget the comma
   onPrepare: function() {
      //your code
   }
}

Upvotes: 1

Aleksey Solovey
Aleksey Solovey

Reputation: 4191

You had issues with the syntax, where you needed : to separate the key (onPrepare) and a value (function).

Also you are missing a comma (,) between capabilities and onPrepare keys.
Here is code that you need:

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['PageObjectLocator1.js'],
  capabilities: {
    browserName: 'chrome'
  },
  onPrepare: function() {
    //your code 
  }
}

Upvotes: 3

Related Questions