Monday, January 25, 2016

Capturing Page JavaScript Errors Using Selenium WebDriver


public void printPageErrors() throws Exception {
    //Capture all errors and store them In array.
    List Errors = JavaScriptError.readErrors(driver);
    System.out.println("Total No Of JavaScript Errors : " + Errors.size());
    //Print Javascript Errors one by one from array.
        for (int i = 0; i < Errors.size(); i++) {
            System.out.println("Error Message : " + Errors.get(i).getErrorMessage());
            System.out.println("Error Line No : " + Errors.get(i).getLineNumber());
            System.out.println(Errors.get(i).getSourceName());
            System.out.println();
        }
 }


Note: Need to download "JSErrorCollector-0.5.jar"
need to download "JSErrorCollector-0.5.jar"

No comments:

Post a Comment