【发布时间】:2019-10-25 18:47:36
【问题描述】:
正如标题所示,在实际操作之前,我正在对 Web 元素进行一些标准检查。检查元素是否显示和启用。我想将这两项检查分开,因为我想要一个失败的具体原因。感觉下面的代码太长了。
任何建议都将不胜感激。
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!");
}
【问题讨论】: