简体   繁体   中英

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.

在此处输入图片说明

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 
  }
}

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
   }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM