teerapap / grunt-protractor-runner

A Grunt plugin for running protractor runner.
MIT License
149 stars 123 forks source link

[Question] Passing baseUrl into tests #122

Open ch0wdan opened 9 years ago

ch0wdan commented 9 years ago

Hey guys,

I'm trying to figure out how to get the Gruntfile to contain multiple baseUrl's (so i can specify for uat, staging, localhost), either specified in different protractor.config.js files.

I see we can specify a config file, is there a way to set that config file so that it will be read when we run a grunt.taskrunner such as "grunt test:e2e_uat"? Or is there a way we can set a taskrunner to read a specific baseUrl such as "baseUATUrl:"?

ch0wdan commented 9 years ago

So i my protractor {} setup to have a staging argument.

I guess the biggest thing i'm trying to solve is, how do i pass the baseUrl: thats specified in protractor args to my spec files?

What I am trying to do is get baseUrl: into browser.get() that is specified in the spec

Heres what i currently have in my Gruntfile.js protractor: { options: { configFile: 'protractor.conf.js', args: { baseUrl: 'http://localhost:9000' } }, staging: { options: { configFile: 'protractor.conf.js', args: { baseUrl: 'http://tetris-staging.com', browser: 'chrome' } } } },

deerawan commented 8 years ago

@ch0wdan You can use params like below

  protractor: {
    ....
    staging: {
      options: {
        keepAlive: false,
        args: {
          params: {
             baseUrl: 'http://tetris-staging.com'
          }
        }
      }
    }

You can access it in your tests file using browser.params.baseUrl like below

browser.get(browser.params.baseUrl)