Eric Brown - Cal Eric Brown - Cal - 1 year ago 92
Javascript Question

Protractor, login to asp,net MVC login page, wait for default page then , redirect to angular page and do

I'm trying to implement Protractor test on my MVC Project that we are slowly converting to Angular

I login on a MVC login page, enter the login and password, Click login, then I need to wait for the login to go through several pages, and get to the default screen.

Then I need to redirect to one of my Angular pages and run a simple test (button = enabled).

I think this is what I need to do, and if Im correct, I failing at the wait for several redirects to end up at default page. I'm redirecting to my page before the whole login process is finished.

Here is what I have:

// spec.js
//ptor = protractor.getInstance();
describe('ScoutAngular Protractor Tests', function () {

beforeEach(function () {
browser.ignoreSynchronization = true;


it('should login and goto the angular page', function () {

var submit = browser.driver.findElement(protractor.By.tagName('input'));
browser.ignoreSynchronization = false;
function ()
console.log("===================== 1");

//<<<<<--------I think i need to wait for login to finish several page redirects here

.then(function () {
console.log("===================== about to expect");
console.log("===================== 4");


When I get to my TestAngularEWB page I'm getting a user not logged in error...

How can I make it wait for the default page, before redirecting to TestAngulareEWB?

Am I making any other total noob protractor mistakes?

Answer Source

If you know which URL ends the redirect chain, you can use browser.wait() to wait for current URL to become equal to an expected one:

var urlChanged = function(expectedUrl) {
  return function () {
    return browser.getCurrentUrl().then(function(actualUrl) {
      return expectedUrl === actualUrl;

browser.wait(urlChanged(""), 5000); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download