Code failed to catch WebElementNotFoundException

In my test case, I am trying to click a button, if it exists on the page. My script for this looks like:

`
void clickEditButton() throws WebElementNotFoundException {
try {
WebUI.click(findTestObject(‘Object Repository/TableRowEditButton(TabbedPane)’))
}
catch (WebElementNotFoundException ex) {
WebUI.click(findTestObject(‘Object Repository/TableRowEditButton(General)’))
}
}

try {
clickEditButton()
}
catch (WebElementNotFoundException ex) {
break;
}
`

and for some reason, it’s failing with the “Unable to click on object” exception, even though I caught it. Even worse, when I go to the line number that failed, it’s the one inside the try block, inside clickEditButton.

Hey Michael

I agree, pretty insane. Try that JS solution in the other thread – it’s more direct A lot of this stuff built on top of WebDriver code just adds layers of unnecessary confusion (in my not so humble opinion B))