我使用了以下代码并处理了异常:
Boolean bIsElementPresent = IsElementPresent(By.xpath("//input[@value='OK']"));
if (bIsElementPresent)
{
driver.findElement(By.xpath("//input[@value='OK']")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//span[(@class='rtsTxt') and (text()='olicy / Status')]")).click();
// Again click on Policy / Status
Thread.sleep(2000);
}
异常处理:
private Boolean IsElementPresent(By by) {
// TODO Auto-generated method stub
try
{
driver.findElement(by);
return true;
}
catch (NoSuchElementException)
{
return false;
}
}
但是对于catch(NoSuchElementException) 我收到语法错误:
**Syntax error, insert "VariableDeclaratorId" to complete FormalParameter**
如何删除此错误??? 什么是VariableDeclaratorId来完成FormalParameter ??
请帮助