I am testing a single page app, the navigation page is revealed when the user clicks the appropriate icon. I wanted to check and see prior to clicking if the page is already open. On the page is a company name label. It is only actually visible to the naked eye when the navigation page is displayed.
The problem that I am running into is that .isDisplayed()
is returning true
when I use that. I have also used EC.visibilityOf()
which returns true
as well. The below works, I am just not happy with it and am wondering if there is a better way.
navigationOpenClick() {
if (this.EC.elementToBeSelected(this.navPage.companyName)) {
this.navIcon.click();
}
}
My brain had some flatulence and forgot that .isDisplayed()
returns a promise. Once I resolved the promise, the .isDisplayed()
worked like it should.
My not "hacky" working code is below:
navigationOpenClick() {
this.navPage.companyName.isDisplayed().then((displayed) => {
if (!displayed) {
this.navIcon.click();
};
});
}