When I am loading a webpage in selenium html driver, there is Javascript execution error, but there is also this in the error logs
java.lang.ClassCastException: com.gargoylesoftware.htmlunit.javascript.host.Window cannot be cast to com.gargoylesoftware.htmlunit.javascript.host.Console at com.gargoylesoftware.htmlunit.javascript.host.Console.error(Console.java:132) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
I have checked error method in the Console class
/**
* This method performs logging to the console at "error" level.
* @param cx the JavaScript context
* @param thisObj the scriptable
* @param args the arguments passed into the method
* @param funObj the function
*/
@JsxFunction
public static void error(final Context cx, final Scriptable thisObj,
final Object[] args, final Function funObj) {
final WebConsole webConsole = ((Console) thisObj).getWebConsole();
final Formatter oldFormatter = webConsole.getFormatter();
webConsole.setFormatter(FORMATTER_);
webConsole.error(args);
webConsole.setFormatter(oldFormatter);
}
All Scriptable objects are not subclasses of console, so why is this here?