How to install protractor (v1.4.0) baseUrl using the protractor API instead of the configuration file?

I am using protractor v1.4.0 and I want to install the protractorUrl database from the command line, so I cannot use

baseUrl: 'http://localhost:8000/',

config in the protractor configuration file. I want to define the default value for the base url with the params parameter in the protractor configuration file as follows:

params: { baseUrl: 'http://localhost:8080/' },

and then overwrite the default value by passing the new value from the command line when I started the protractor as follows:

protractor 'path_to_my_conf_file' --params.baseUrl http://localhost:80/

then in my spec file I need to set the base url using the protractor APIs, but I can not find how to do this.

The 1st answer to the next question is exactly what I need, but it does not work.

How can I dynamically add URLs to Protractor tests?

+5
source share
4 answers

You can simply change it from the command line as follows:

 protractor --baseUrl http://whateveryouwant 
+4
source

Alternatively, you can also try browser.baseUrl = "https://test-url.com" in onPrepare (works in Protractor 1.4.0)

+6
source

Run tests through grunt with grunt-protractor-runner and grunt-option :

 protractor: { options: { configFile: "path_to_my_conf_file", args: { baseUrl: grunt.option('baseUrl', 'http://localhost:80/') } } } 

Then run the task with:

 grunt protractor --baseUrl=http://mynewurl 

And, to use it as the default baseUrl , just run:

 grunt protractor 
+2
source

Use gulp for your test run; below is the value of gulpfile.js

 var gulp = require('gulp'); var runSequence = require('run-sequence'); var protractor = require('gulp-protractor').protractor; gulp.task('protractor', function() { var configFile = 'test/e2e/protractor-config.js'; return gulp .src(['./test/e2e/spec/sample.js']) .pipe(protractor({ configFile: configFile, args: ['--baseUrl', 'http://www.google.com'] })) .on('error', function(e) { throw e; }); }); gulp.task('test', function(callback) { runSequence( 'protractor', callback ); }); 

Task Launch:

 gulp test 
0
source

Source: https://habr.com/ru/post/1208265/


All Articles