User
User

Reputation: 23

wait for page load for non-angular Application using protractor

i am new to protractor and testing Non-Angular login Page and on clicking login button on login page a new page appears and i need to click on a planning link.But on clicking Login button application takes around 50 seconds.I want the protractor to wait untill the planning link appears.I used browser.wait(),browser.driver.implicitltyWait() but no success. I am able to click on planning link using browser.sleep() only. Please help me to resolve the issue.

Upvotes: 0

Views: 5598

Answers (3)

Brine
Brine

Reputation: 3731

I wrote a blog post about this, and have working examples on github, specifically when testing non-Angular apps. It makes use of Expected Conditions, and Page Objects.

If you're not using Page Objects yet, you'd do something like:

var EC = protractor.ExpectedConditions;
// Waits for the element with id 'loginBtn' to be clickable.
browser.wait(EC.elementToBeClickable($('#loginBtn')), 50000);

Upvotes: 0

vsathyak
vsathyak

Reputation: 73

So what I understood from your question is that you have a non angular login page and click on login button takes you to another page(Is this angular or non angular?) which takes around 50 sec to load and contains a link(planning). Right?? And clicking on that link will take you to your angular home page.

And the issue which you are facing now is that the protractor is not waiting 50sec for the page containing the planning link to load.

Please try this and let me know the result..

this.clickLoginBtn = function () {
    browser.driver.findElement(loginBtn).click();
    return browser.wait(function () {
        return browser.driver.isElementPresent(planningLink);
    }, 50000);
};

I used browser.driver.findElement since we are on the non angular page.

Upvotes: 0

Sudharsan Selvaraj
Sudharsan Selvaraj

Reputation: 4832

You need to wait for any WebElement in the page that is loaded after you perform login operation.

var EC = protractor.ExpectedConditions;

browser.wait(EC.visibilityOf(element(by.id("someId"))),60000)

it will wait for the element and throw exception after waiting for 1 minute

Upvotes: 0

Related Questions