Hi all,
Every time exception throws while running the selenium test, we can't know whats the original place its thrown. So you can write an exception handler by own so that it will throw the type.
Here is the ExceptionHandler.Java file.
package SeleniumUtils;
import java.lang.Exception;
@SuppressWarnings("serial")
public class ExceptionHandler extends Exception {
public String functionName;
public String errorMessage;
public ExceptionHandler(String functionName, String errorMessage) {
this.functionName = functionName;
this.errorMessage = errorMessage;
}
public String toString(){
return "\nFunction Name: " +this.functionName+ "\nError Message: " +this.errorMessage+ "\n" ;
}
}
So, just write your handler in your script like below to control your script.
function abc() {
if (isElementPresent(locator))
sel.click()
else
throw new ExceptionHandler ("function111", "Error while doing click.")
}
Comments
Post a Comment