I have a piece of code in protractor to do a wait:
public waitForElement() {
return browser.wait(
ExpectedConditions.visibilityOf(element(by.id('#someEl'))),
10000,
'Unable to find the element'
);
}
My issue is that I cannot seem to catch this exception if it times out. I tried adding a catch() clause, which does not work, e.g.:
this.waitForElement()
.then(() => { /* do something */ })
.catch(() => { /* handle the error -- this code never happens if there is a timeout!!! */ });
I tried putting the code in a try-catch block, but that doesn't help either:
try { this.waitForElement().then(() => { }); }
catch (ex) { /* this exception is never caught, the test just fails!! */ }
I'm stumped: how can I catch the wait timeout and continue with the test without the test failing?