angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.75k stars 2.31k forks source link

Troubles with non-angular login page after updating to 2.0.0 #1962

Closed ricogallo closed 9 years ago

ricogallo commented 9 years ago

Hi, I have a protractor.conf.js really similar to the one you use for login in the repo specs. I employ an onPrepare function that invokes the browser.driver.get and then there is a browser.driver.wait. Everything was fine until I updated to the latest version of protractor. But I've found that if I put the onPrepare code inside my Jasmine tests (inside a beforeEach, for instance), it works again.

I guess there is an issue wrapping Jasmine?

This is my troubleshoot output.

Cheers!

DEBUG - Running with --troubleshoot
DEBUG - Protractor version: 2.0.0
DEBUG - Your base url for tests is http://localhost:8080
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
DEBUG - WebDriver session successfully started with capabilities { caps_: 
   { platform: 'MAC',
     acceptSslCerts: true,
     javascriptEnabled: true,
     browserName: 'chrome',
     chrome: { userDataDir: '/var/folders/bq/cm6ls90j0xn0kqw8qkscmbwm0000gn/T/.org.chromium.Chromium.1DXf0h' },
     rotatable: false,
     locationContextEnabled: true,
     mobileEmulationEnabled: false,
     'webdriver.remote.sessionid': 'c5054c16-7f14-4b32-9560-69fcbc9ca1a9',
     version: '41.0.2272.101',
     takesHeapSnapshot: true,
     cssSelectorsEnabled: true,
     databaseEnabled: false,
     handlesAlerts: true,
     browserConnectionEnabled: false,
     nativeEvents: true,
     webStorageEnabled: true,
     applicationCacheEnabled: false,
     takesScreenshot: true } }
glepretre commented 9 years ago

I have the same issue with a manually bootstrapped angular app (without the browser.driver.wait part):

With Protractor 1.8.0:

protractor.conf.js

onPrepare: function() {
  browser.get('path/to/index.html');
},

With Protractor 2.0.0: I have to call browser.get at the beginning of my tests, otherwise I get:

 Error while waiting for Protractor to sync with the page: "angular could not be found on the window"

We never encountered issues like #66 before.

Let me know if you want me to provide more debug info :wink:

juliemr commented 9 years ago

@ricogallo can you provide your config file including onPrepare function? We need to know if you're using jasmine 1.3 or 2 and what your onPrepare actually looks like.

glepretre commented 9 years ago

@juliemr I'm using jasmine 1.3, and my on full config is:

exports.config = {
  seleniumAddress: 'http://127.0.0.1:4444/wd/hub',

  specs: [
    '../e2e/**/*_test.js'
  ],

  multiCapabilities: [
    {'browserName': 'chrome'},
    {'browserName': 'firefox'}
  ],

  baseUrl: 'http://localhost:8000',

  onPrepare: function() {
    // https://gist.github.com/elgalu/82929eeeef4a80e01835
    browser.getCapabilities().then(function(s) {
      var browserName = s.caps_.browserName;

      browser.isFirefox = function() {
        return /firefox/.test(browserName);
      };

      browser.isChrome = function() {
        return /chrome/.test(browserName);
      };
    });
    browser.driver.manage().window().maximize();
    browser.get('e2e/index.html');
  },

  jasmineNodeOpts: {
    isVerbose: true
  }
};
ricogallo commented 9 years ago

Hi @juliemr , sorry for the late reply. It seems that adding framework: 'jasmine2' to the config file solved it! Thanks

glepretre commented 9 years ago

@ricogallo Lucky you if you can switch to jasmine2 so easily! :smile:

@juliemr Should I open a dedicated new issue for our case?

juliemr commented 9 years ago

@glepretre please do open a new issue, I'm closing this one. It would be helpful if you can add more information from the test output as well, since I'm not sure what is triggering the timeout.