0

初学者selenium2.0请教大侠在网页时抛出异常。 selenium2.0是如何捕获和处理页面异常?selenium2.0如何处理异常问题

我不想停下来,让整个测试过程因为不寻常的问题。是否有像qtp恢复功能的场景?如果我们平时遇到这个异常问题是如何解决的...

谢谢!!

+0

你可以举一个你的意思是“异常”问题的例子吗?抛出异常是有原因的,你想要捕捉异常的一个原因是用更多的信息重新抛出异常。 – Arran

回答

0

看看这个Oracle Java Tutorial about Exceptions

简短的回答是,所有的WebDriver方法都会抛出特定类型的Exceptions,您可以捕捉并处理它们。

WebElement elem = null; 
try { 
    elem = driver.findElement(By.id("someId")); 
} catch (NoSuchElementException e) { 
    log.error(e.getMessage()); 
    throw e; // or not if this error was expected, program then continues 
}