user7364588
user7364588

Reputation: 1144

Passing parameters to browser.get - protractor

Context :

Issue :

How do protractor's browser method get takes url parameters query ?

browser.get('${browser.baseUrl}?p=2') is redirecting to http://localhost:4200/&p=2 instead of http://localhost:4200&p=2.

When i supress last character of browser.baseUrl, the redirected url is http://localhost:420/&p=2 ...

Any idea ?

Edit :

I tried edit protractor.conf.js by adding baseUrl but i does not change anything ...

Upvotes: 1

Views: 389

Answers (1)

Yevhen Laichenkov
Yevhen Laichenkov

Reputation: 8672

If you set a baseUrl in the config file, then there is no need to add browser.baseUrl in the get method, you can omit it.

For instance, in the config you have:

exports.config = {
   // ...

   baseUrl: 'https://github.com/search',
}

In the test, you can just add the query parameters like this:

it('should open the URL with the query parameter', async () => {
  await browser.get('?q=test'); // will open the 'https://github.com/search?q=test' page
});

Upvotes: 1

Related Questions