Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the current browser name in Protractor test

I'm creating users in some test. Since it is connected to the backend and create real users I need fixtures. I was thinking of using the browser name to create unique user. However, It has proven to be quite difficult to get to it...

Anyone can point me in the right direction?

like image 633
Syl Avatar asked May 26 '14 15:05

Syl


People also ask

How do you find the browser name on Protractor?

getCapabilities(). then(function (cap) { browser. browserName = cap.

How do you find the current URL in a Protractor?

If you want to just check the current URL, then use browser. getCurrentUrl() : expect(browser. getCurrentUrl()).

How do I refresh my Protractor browser?

refresh() is used to refresh the current page or making a full reload of the current page in Protractor. It assumes that the current application is an angular application and waits to load before executing the next command.

How do I run multiple browsers on a Protractor?

If you would like to test against multiple browsers, use the multiCapabilities configuration option. Protractor will run tests in parallel against each set of capabilities. Please note that if multiCapabilities is defined, the runner will ignore the capabilities configuration.


1 Answers

Another case of rubber ducking :)

The answer was actually quite simple.

in my onPrepare function I added the following function and it works flawlessly.

browser.getCapabilities().then(function (cap) {
  browser.browserName = cap.caps_.browserName;
});

I can get access the name in my test using browser.browserName.

like image 57
Syl Avatar answered Oct 19 '22 01:10

Syl