htmldriver中的类强制转换异常

时间:2017-02-15 14:05:53

标签: java selenium htmlunit-driver

当我在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对象都不是控制台的子类,为什么会这样?

1 个答案:

答案 0 :(得分:0)

感谢报道。

2.25-SNAPSHOTthis commit修正了此问题。