当我在selenium html驱动程序中加载网页时,出现Javascript执行错误,但错误日志中也有此错误
java.lang.ClassCastException: com.gargoylesoftware.htmlunit.javascript.host.Window无法转换为 com.gargoylesoftware.htmlunit.javascript.host.Console at com.gargoylesoftware.htmlunit.javascript.host.Console.error(Console.java:132) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
我已在Console类中检查了错误方法
/**
* 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);
}
所有Scriptable对象都不是控制台的子类,为什么会这样?