java捕获带有日志的NoSuch元素。webdriver中的错误?
我在webdriver测试中添加了log4j(apache软件)作为记录器
我想知道你的日志。错误语句应作为良好实践放在catch block中
我们不是应该使用异常e对象,然后像这样处理e吗: e、 printStackTrace()
添加日志是否合适。错误进入捕捉区
public static WebElement destinationTextBox(WebDdriver driver){
try{
element = driver.findElement(by...) ; //this can raise exception if no element found
}
//it will be caught here
catch(NoSuchElementException e){
log.error( "no element found") ;
}
// if element found and no exception, just log 'element found'
log.info(Destination text box element found) ;
共 (0) 个答案