Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

browser.get() does not wait for Angular before page load #2461

@sashee

Description

@sashee

If I have an Angular page that I am navigating from, the browser.get() call does not wait for the original page to settle. This makes use cases like this fragile:

  1. Open login page
  2. Fill in login details
  3. Click on the login button
  4. Open an application page
  5. Do something as a logged in user

This results in a race condition between the click on step 3) and the page load on step 4), resulting in a flickering test.

I made a minimal project to serve as an example for this at: https://github.com/sashee/protractor-problem-example . You can check the very same workflow at the spec file: https://github.com/sashee/protractor-problem-example/blob/master/spec.js

The login is substituted with a simple $timeout, but in a real app this would be a $http call that the $httpBackend intercepts and returns a canned response. Thus it's length is undetermined, if you play around with the exact timings (https://github.com/sashee/protractor-problem-example/blob/master/login-controller.js#L8) you can easily find a value when the spec passes, and one when fails (try with 2ms and 500ms)

If I manually call waitForAngular() before browser.get(), then the test pass every time (see: https://github.com/sashee/protractor-problem-example/blob/master/spec.js#L12)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions