As the title suggest, I'm doing some standard checking of an web element before the actual action. Check like if the element is displayed and enabled. I want to separate the the two checking because I want a specific reason why it fail. I feel the code below is too long.
Any suggestion would be appreciated.
Boolean isActionSuccess = false;
if (currentObject.isDisplayed()) {
if (currentObject.isEnabled()) {
// move to the object before clicking
CommonFunctions.silentWait(1);
actionToE.moveToElement(currentObject).perform();
if (!actionPar.isEmpty()) {
// do something else
} else {
currentObject.sendKeys(Keys.ARROW_UP);
isActionSuccess = true;
}
} else {
System.out.println("Web Element is disabled!");
}
} else {
System.out.println("Web Element is not displayed!");
}