I want to try to click an ElementFinder, so that in case of error during click, the tests will be not marked as failed and no error will be placed on console.
Unfortunately, my method:
static tryToClick(elem: ElementFinder) {
// I want to ignore all errors, just try to click and if not proceed
if (elem.isPresent() && elem.isDisplayed() && elem.isEnabled()) {
try {
browser.wait(protractor.ExpectedConditions.elementToBeClickable(elem), 999).then(function() {
elem.click().then(function() {try {} catch (error) {} } );
});
} catch (error) {}
}
}
still produces an error on the console:
- Failed: stale element reference: element is not attached to the page document
thus I don't understand why it is not handled in the try-catch block.