How to handle redirect when writing testing with angularjs?

There is a basic document about how to run E2E testing with angularjs: http://docs.angularjs.org/guide/dev_guide.e2e-testing

In my project, I use angularjs for a multi-page web applications. When I click a link in the page, it will open a whole new page. And there is a login page, I must login before testing.

I will do following in my test:

  1. Visit the login page
  2. Input username and password
  3. Submit the form
  4. Visit the real page I want to test
  5. Test the page

But I don't find any information about redirect in that document. What should I do?

Don't worry about test preparation. The whole thing happens into an iframe that can live by its own.

So, if you click on a link where redirection occurs, it will redirect anyway.

Notice that there is no special setup section in e2e test with angular, that means everything is a test, which means your setup phase is also a test.

What you can do is a first test that prepare the setup correctly :

describe('My Whole Test Suite', function () {


    it('Should be able to access page', function () {
        browser().navigateTo('/whereSetupOccurs');
        input('#username').enter('john');
        input('#password').enter('psswrd');

        // when you click redirection happen anyway
        element('#submit').click();

        //check that redirection was made properly
        expect(browser().location().url()).toContain("/whereIWantedToGoForMyTests");

    });


    it('Should be able to ...', function () {
        // the real tests you wanted here
    });

});