Reputation: 164
We are using protractor to test our front end angular app that we are building.
Currently we are using browser.get()
to specify our environement we wish to test again(localhost:9000, staging, UAT) however I am wanting to parameterize this so that when we run our tests using grunt test:e2e
we can specify a parameter to change the browser.get()
to a specified environment.
Something like being able to call grunt test:e2e NODE_ENV=uat
to test against specified environment.
Anyone have any insight to how to do this?
Upvotes: 6
Views: 8225
Reputation: 188
You can pass any number of arguments to protractor You need to pass parameters within the protractor task in your grunt file. Here is small snippet
config: grunt.file.readJSON('config-param.json'),
protractor: {
options: {
configFile: "config/e2e.conf.js", // Default config file
keepAlive: true, // If false, the grunt process stops when the test fails.
noColor: false, // If true, protractor will not use colors in its output.
debug: '<%= config.debugger %>',
args: {
params: '<%= config %>'
}
},
run: {}
},
and you can access parameters in your specs like. browser.params.fieldName
Upvotes: 8
Reputation: 473843
The common way to approach the problem is to use baseUrl
command-line argument:
protractor --baseUrl='http://localhost:9000' protractor.conf.js
Or, you can set the webdriver.base.url
environment variable:
webdriver.base.url=http://localhost:9000
You can also use a task manager (e.g. grunt
and grunt-protractor-runner
) and configure different tasks for running tests in a different environment setting different baseUrl
s.
Upvotes: 4