I am using spectron 3.8.0 and am trying to check if am element exists in the DOM. I tried using the waitUntil
method with try/catch
, but it didn't work as expected. Recently I got sync app.client.isExisting()
return true if an element exists, but otherwise it gets stuck and throws a timeout exception (mocha).
Code below:
@log
protected async isExisting(element: string, name?: string): Promise<boolean> {
await this.app.client.isExisting(element)
.then(data => {
const isExisting = data;
console.log(CONSOLE_COLORS.YELLOW, "IS EXISTING???", isExisting);
return isExisting;
})
.catch(e => {
console.log(CONSOLE_COLORS.RED, "no existing elem")
return false;
});
}