Search code examples
javascriptprotractorend-to-end

Make Protractor sequentially route to different URLs


As expected, browser.get("http://www.google.com"); routes us to Google.

My question however, concerns routing to different webpages sequentially. I have the use case to route to a set of (hard coded) pre-defined URLs sequentially, and check each web page for a 404.

Let's say I have the following URLs that I want Protractor to route to:

http://www.google.com
http://www.amazon.com
http://www.ebay.com

And the following end-to-end code:

describe("Test links for validity", function() {
    it("should route to Google", function() {
        browser.get("http://www.google.com");
        expect(browser.driver.getCurrentUrl()).not.toContain("/Error/");
    });

    it("should route to Amazon", function() {
        browser.get("http://www.amazon.com");
        expect(browser.driver.getCurrentUrl()).not.toContain("/Error/");
    });

    it("should route to Ebay", function() {
        browser.get("http://www.ebay.com");
        expect(browser.driver.getCurrentUrl()).not.toContain("/Error/");
    });
});

The problem I face is that Protractor beautifully routes to Google... and then idles. Is there something I miss that makes Protractor actually route to Amazon and Ebay as well?

Your help is very much appreciated!


Solution

  • The fix is simple!

    Instead of using browser.get("http://www.google.com"); use browser.driver.get("http://www.google.com");. This way you are communicating directly to the Web Driver.