title: A Jasmine spec timed out. Resetting the WebDriver Control Flow - when redirect to new page
body: <p>I'm beginner in the e2e testing and have a problem.
  When I do login - I make redirect from login.php to index.php page.
  But my test is fails with following errors:</p>
  
  <pre><code>..A Jasmine spec timed out. Resetting the WebDriver Control Flow.
  F
  
  Failures:
  1) Login Page should login and redirect to overview page with CR Operators rights.
    Message:
      Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
    Stack:
      Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
  
  3 specs, 1 failure
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>it('should login and redirect to overview page with CR Operators rights', function(sync) {
      element(by.model('username')).clear().sendKeys('testuser');
      element(by.model('password')).clear().sendKeys('test');
      element(by.css('[type="submit"]')).click();
      expect(browser.getLocationAbsUrl()).toMatch('/overview');
  });
  </code></pre>
  
  <p>So the question is how i can wait when my page will reload and check url?</p>
  
  <p><strong>UPD</strong></p>
  
  <p>I make an Ajax POST request and if login/pass are correct I do redirect to /index.php</p>
  
  <p><strong>UPD 2</strong></p>
  
  <p>I have tried several constructions with browser.wait (browser.driver.wait) but without any success:</p>
  
  <pre><code>it('should login and redirect to overview page with CR Operators rights', function(done) {
      element(by.model('username')).clear().sendKeys('testuser');
      element(by.model('password')).clear().sendKeys('test');
      element(by.css('[type="submit"]')).click();
  
      setTimeout(function() {
          expect(element(by.css('body')).getText()).toContain('Welcome Test User');
          done();
      }, 1000);
  });
  </code></pre>
  
  <p>and </p>
  
  <pre><code>it('should login and redirect to overview page with CR Operators rights', function(done) {
      element(by.model('username')).clear().sendKeys('testuser');
      element(by.model('password')).clear().sendKeys('test');
      element(by.css('[type="submit"]')).click();
  
      browser.driver.wait(function() {
              return browser.driver.getCurrentUrl().then(function(url) {
                  console.log(url);
                  return (/overview/).test(url);
              });
          }, 5000);
      expect(browser.getLocationAbsUrl()).toMatch('/overview');
      done();
  });
  </code></pre>
  
  <p>everything of these don't work :( <strong>BUT</strong> when I don't use <em>browser</em> or <em>element</em> - it works. E.g.:</p>
  
  <pre><code>it('should login and redirect to overview page with CR Operators rights', function(done) {
      element(by.model('username')).clear().sendKeys('testuser');
      element(by.model('password')).clear().sendKeys('test');
      element(by.css('[type="submit"]')).click();
  
      setTimeout(function() {
          expect(true).toBe(true);
          done();
      }, 1000);
  });
  </code></pre>
  
  <p>So I guess that here is a problem when use <em>browser</em> and <em>element</em> after redirect.</p>
  
  <p>Any thoughts?</p>