Handling try catch for an if statement in Selenium Webdriver
<pre><code>public void verifyErrorMsgforInvalidUserTransPosting(
{
String errorMSG="You dont have permission to create transaction using this ID";
String errorMSGSYS=driver.findElement(By.xpath("html/div/.....").getText();

if(errorMSGSYS.equals(errorMSG))
    {
        System.out.println("System didnt allowed user to post the Transaction");
        report.updateTestLog("Verify System is NOT allowing user to post transaction for an invalid user", "System didnt allowed user to post the Transaction", Status.SCREENSHOT);
    }
    else
    {
        System.out.println("System is allowing user to post the Transaction which is NOT expected behavior");
        report.updateTestLog("Verify System is NOT allowing user to post transaction for an invalid user", "System is allowing user to post the Transaction which is NOT expected behavior", Status.FAIL);
    }
}
</code></pre>

<p>In the above code, if(condition 1) will work when the element is found and if the condition1 satisfies 
else statement works when there is a mismatch</p>

<p>Could some one help me how can i handle the else when the element is NOT found using try catch or any other method.</p>