How to wait for a website to load completely using protractor
<p>I am working on creating a test scripts for a non angular js website using protractor. My code is as follows :</p>

<pre><code>var co = require('co');
var path = require('path');

describe("TEST", function () {

    it("test", co.wrap(function* () {
        browser.ignoreSynchronization = true;

        yield browser.get(URL, 60000);
        browser.sleep(5000);// I want to remove the sleep statements
        var elmOK = browser.driver.findElement(by.css('a[href="#login"]'));
        yield elmOK.click();
        expect(browser.getCurrentUrl()).toContain("login");
        yield browser.switchTo().frame('here-account-sdk').then(function () {
            browser.driver.findElement(by.id('sign-in-email')).sendKeys("uid");
            browser.driver.findElement(by.id('sign-in-password-encrypted')).sendKeys("password");
            browser.driver.findElement(by.xpath(' //*[@id="sign-in-form"]/div[2]/div[6]/form/fieldset[3]/button')).click();

        });
        browser.sleep(5000);// I want to remove the sleep statements
        var elmOK = browser.driver.findElement(by.xpath('//*[@id="lnav"]/li[3]/a'));
        yield elmOK.click();
        browser.sleep(1500);// I want to remove the sleep statements
        browser.driver.findElement(by.xpath('//*[@id="administration"]/div/div[1]/select/option[2]')).click();
        browser.sleep(5000);// I want to remove the sleep statements

        browser.driver.findElement(by.xpath('//*[@id="administration"]/div/div[2]/table/tbody/tr[1]/td[10]/span')).click();
        browser.sleep(5000);// I want to remove the sleep statements

        browser.driver.findElement(by.xpath('//*[@id="content"]/div/div[2]/div/div/div/div[3]/button[1]')).click();//Delete the file
        browser.sleep(5000);// I want to remove the sleep statements
    }));




});
</code></pre>

<p>If I add sleep in my code the test runs as expected. But I want to remove sleep statements from my code completely. I referred to many other stack overflow questions but it didn't help. :( </p>

<p>I first used <code>browser.manage().timeouts().implicitlyWait(5000);</code> but I think there was no delay in loading my url.</p>

<p>I used expected condition but it was also not working.</p>

<p>I added <code>browser.wait(1000)</code> but my script fails. Please advice me as I feel bit lost in this problem.</p>