I added log4j(apache software) as logger to my webdriver testing.
I wonder if log.error statements should be put in catch block as good practice?
Are not we supposed to use exception e object and just work with e like this: e.printStackTrace()?
Is it a proper practice to add log.error into catch block?
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) ;
Aucun commentaire:
Enregistrer un commentaire