I am testing a page using protractor. Of the various test cases, I need to wait until the objects have loaded. The following are excerpts from the scripts. While this does not display any errors, it fails to wait for the object to appear and the test cases fail until the page is able to catch up.
login.e2e-spec.ts
it('should display company logo', () => {
page.navigateTo();
page.clickImplicitGrantButton()
.then(() => browser.wait(ExpectedConditions.visibilityOf(browser.getLogo()), 10000))
.then(() => page.isLogoVisible()
.then((isVisible) => {
expect(isVisible).toBe(true);
}));
});
login.po.ts
clickImplicitGrantButton() {
return $('button.mat-button#implicit').click();
}
getLogo() {
return browser.driver.findElement(by.className('main-logo'));
}
isLogoVisible() {
return this.getLogo().isDisplayed();
}
.findElement()which waits for angular to finish loading before searching for elements. You mentioned this is a non-angular page. Try using just.element()instead. - tehbeardedonemain-logoor theImplicitGrantButton. If it's the latter, you did not wait it appear in functionclickImplicitGrantButton(). - yong