colin_dev256 colin_dev256 - 1 year ago 76
Node.js Question

Detecting browser with protractor

Is there a way to detect the browser testing my scripts in protractor? Looked everywhere! I'm trying to factor all my different browser specs into one each so that in the config file I simply change the browser name and execute the same script. I've already tried these;

if (isFirefox)

if (browser === 'firefox')

Answer Source

As far as I know you set the browser through the capabilities object right?

You can get the browser that you set here in your test script with

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

Now just check this variable.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download