question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

browserName always IE when waitForAngualrEnabled(false)

See original GitHub issue

Bug report

  • Node Version: v6.11.5
  • Protractor Version: 5.3.0
  • Angular Version: 1
  • Browser(s): all
  • Operating System and Version Win10 1709




exports.config = {


  framework: 'jasmine2',
  allScriptsTimeout: 50000,
  untrackOutstandingTimeouts: true,

  // Capabilities to be passed to the webdriver instance.
  capabilities: {
    name: 'QA Protractor Automation',
    browserName: 'chrome',
   
  },

  params: {
    build: 'daily',
  },

  localSeleniumStandaloneOpts: {
    jvmArgs: ['-Dwebdriver.ie.driver=./node_modules/webdriver-manager/selenium/IEDriverServer3.11.1.exe', '-Dwebdriver.edge.driver=./node_modules/webdriver-manager/selenium/MicrosoftWebDriver.exe'],
  },
 
  beforeEach: function () {
    browser.executeScript('window.e2e = true;')
  },

  onPrepare: function () {
   
    // onPrepare browser config
    browser.driver.manage().window().maximize();
    browser.manage().timeouts().implicitlyWait(0);
    browser.getProcessedConfig().then(function (c) {
        if (c.capabilities.browserName == "internet explorer")
            browser.waitForAngularEnabled(false);
    })
    browser.executeScript('window.e2e = true;');
   
    browser.waitForAngularEnabled(false);
    browser.get('https://angular.io/');

    //use either or
    browser.driver.get('https://angular.io/');
  },


  // Spec patterns are relative to the configuration file location passed
  // to protractor (in this example conf.js).
  // They may include glob patterns.*/
  specs: ['./specs/fireFoxSmokeTest.js'],

  // Options to be passed to Jasmine-node.
  jasmineNodeOpts: {
    showColors: true, // Use colors in the command line report.
    defaultTimeoutInterval: 9000000,
  }
}

simple test to recreate

//login does not have Angular Component

it('should be chrome', function () {
    //disable waitForAngular for login page
    browser.getProcessedConfig().then(function (c) {
        console.log(c.capabilities.browserName)
    })
});
**console output from test** 
[17:19:38] I/launcher - Running 1 instances of WebDriver
[17:19:38] I/local - Starting selenium standalone server...
[17:19:40] I/local - Selenium standalone server started at http://172.28.102.81:51936/wd/hub
C:\Users\LeoColeman\Desktop\Version-7-Issue-Tracker\specs\Page Objects
Started
internet explorer

**- Steps to reproduce the bug**
1. either browser.driver.get() or disabled waitforAngualrenabled()
2. getProcessedConfig then console.log(browserName)
3. it will always come back as IE when accessing from browser.driver or when disabled browser.waitForAngular(). 

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
IgorSasovetscommented, Apr 22, 2018

Thanks, @wswebcreation .

1reaction
IgorSasovetscommented, Apr 20, 2018

Take a look at my modification of your example:

exports.config = {
  framework: 'jasmine2',
  allScriptsTimeout: 50000,
  untrackOutstandingTimeouts: true,

  // Capabilities to be passed to the webdriver instance.
  capabilities: {
    name: 'QA Protractor Automation',
    browserName: 'chrome',

  },

  params: {
    build: 'daily',
  },

  localSeleniumStandaloneOpts: {
    jvmArgs: ['-Dwebdriver.ie.driver=./node_modules/webdriver-manager/selenium/IEDriverServer3.11.1.exe', '-Dwebdriver.edge.driver=./node_modules/webdriver-manager/selenium/MicrosoftWebDriver.exe'],
  },

  directConnect: true,
  onPrepare: async function () {

    // onPrepare browser config
    await browser.driver.manage().window().maximize();
    await browser.manage().timeouts().implicitlyWait(0);
    const conf = await browser.getProcessedConfig();
    console.log('PREPARE:' + conf.capabilities.browserName);
    if (conf.capabilities.browserName == 'internet explorer')
        browser.waitForAngularEnabled(false);
    browser.executeScript('window.e2e = true;');
    browser.waitForAngularEnabled(false);
  },


  // Spec patterns are relative to the configuration file location passed
  // to protractor (in this example conf.js).
  // They may include glob patterns.*/
  specs: ['small-example-get-config.js'],

  // Options to be passed to Jasmine-node.
  jasmineNodeOpts: {
    showColors: true, // Use colors in the command line report.
    defaultTimeoutInterval: 9000000,
  }
}

and small-example-get-config.js

'use strict';

describe('Small test example', () => {
  beforeEach(() => {
    browser.executeScript('window.e2e = true;');
  });
  it('Should navigate to angular.io', async() => {
    await browser.get('https://angular.io/');
    const config = await browser.getProcessedConfig();
    console.log('-------------------------------------');
    console.log(config.capabilities.browserName);
    console.log('-------------------------------------');
    expect(config.capabilities.browserName).toEqual('chrome');
  });
});

As you can see on screen, all works as expected.

capabilitiesbug

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do I need to use waitForAngular(false) & browser.sleep ...
This is why I always run tests with browser.waitForAngularEnabled(false) , but it's super difficult to handle wait.
Read more >
Automating Angular application using Protractor on IE Browser
When this is set to False, the rest of the driver session, Protractor will not sync the Angular calls unless Angular wait is...
Read more >
angular/protractor - Gitter
Is there a way to get the current browser.waitForAngularEnabled() setting? When called, it sets it to true/false. But is there a way ...
Read more >
Automated Cross Browser Testing With Protractor & Selenium
waitForAngularEnabled (false);” ... waitForAngularEnabled(false); ... There are always challenges and limitation to run your test with ...
Read more >
Protractor - Quick Guide - Tutorialspoint
It is always a good practice to write the test because it makes the code better; ... in the same directory i.e. node_modules/Protractor/example....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found