Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add URL's dynamically to Protractor tests?

I am trying to use protractor in conjunction with Jenkins. In my jenkins, I need to have URLs dynamically generated.

So while running protractor tests, for example:

describe('angularjs homepage', function() {
  it('should greet the named user', function() {
    // Load the AngularJS homepage.
    browser.get('http://www.angularjs.org');

    element(by.model('yourName')).sendKeys('testUser');

  });
});

In above example I want to pass a variable dynamically in place of "http://www.angularjs.org".

I could not find any variables that can be specified in the reference config as well.

like image 492
Nilesh Avatar asked Dec 15 '22 23:12

Nilesh


2 Answers

You can use baseUrl as config parameter inside exports.config and then use browser.get('/path') inside your test spec. So in config you have e.g. baseUrl: 'http://localhost', so browser.get('/path') would call http://localhost/path.

like image 54
Sebastian Avatar answered Mar 19 '23 23:03

Sebastian


If I understand the question correctly, you are looking for the environmental variable to configure the base url. In that case, since Protractor is built on WebDriver you should be able to set

webdriver.base.url="http://someurl"

Hopefully this is what you are looking for.

like image 38
user3517049 Avatar answered Mar 19 '23 23:03

user3517049