以下是代码:
try {
WebElement Link_Logout = wait.until(ExpectedConditions.elementToBeClickable(By.id("logoutLink")));
if(Link_Logout.isEnabled()==true)
{
Reporter.log("<br>Step Logout: Customer has been logout successfully");
Link_Logout.click();
Assert.assertTrue(driver.getTitle().contains("Login"));
Reporter.log("<br>Step Logout: Customer has been logout successfully");
}
} catch(Exception exc) {
if(exc instanceof WebDriverException || exc instanceof UnhandledAlertException) {
Reporter.log("<br>Step Logout: Customer has not been logout successfully due to exception");
System.out.println("The exception thrown here is :" +exc);
}
}
注意:try块下的代码正在执行,但reporter.log无效。