我正在尝试避免调用包含
背后的javascript事件的点击事件 <a href="javascript:__doPostBack('grdListe','Select$0')">18-FDG RIM 250MBQ/ML SOLUTION INJECTABLE FLACON MONO DOSE DE 15 ML</a>
在这个java程序中我选择了所有链接,然后单击
final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_38);
final HtmlPage page = webClient.getPage("http://####.com/");
DomElement table= page.getElementById("grdListe");
DomNodeList<HtmlElement> rows= table.getElementsByTagName("tr");
int size=rows.size()-2;
List<HtmlElement> list = rows.subList(1, size);
for (HtmlElement e : list) {
e.click();
}
我得到了这个例外
======= EXCEPTION START ========
Exception class=[net.sourceforge.htmlunit.corejs.javascript.JavaScriptException]
com.gargoylesoftware.htmlunit.ScriptException: Sys.ParameterCountException: Sys.ParameterCountException: Parameter count mismatch. (http://medicaments-maroc.com/ScriptResource.axd?d=jyjiD6NmZgsWAPNSX3rL0rrasCTnD6Q1NsPRxdHfT0VwwhEA4f9pYSUx1U_tgrHyiDC69lrSo4xJuvvtxucOYbUEfgo5UZ8udasbpWce4Y0-08yH67d5GLdX_qq6qNGvB5og0J5eb95EVfKfjNgzkkP0CxRgbnZZGGh3yfJAh0KM7Qyo0&t=2e2045e2#52)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:883)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:815)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.setState(XMLHttpRequest.java:205)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.doSend(XMLHttpRequest.java:784)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.access$000(XMLHttpRequest.java:97)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest$1.run(XMLHttpRequest.java:641)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513)
at com.gargoylesoftware.htmlunit.javascript.background.JavascriptXMLHttpRequestJob.run(JavascriptXMLHttpRequestJob.java:36)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:427)
at com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:156)
at java.lang.Thread.run(Thread.java:744)
Caused by: net.sourceforge.htmlunit.corejs.javascript.JavaScriptException: Sys.ParameterCountException: Sys.ParameterCountException: Parameter count mismatch. (http://medicaments-maroc.com/ScriptResource.axd?d=jyjiD6NmZgsWAPNSX3rL0rrasCTnD6Q1NsPRxdHfT0VwwhEA4f9pYSUx1U_tgrHyiDC69lrSo4xJuvvtxucOYbUEfgo5UZ8udasbpWce4Y0-08yH67d5GLdX_qq6qNGvB5og0J5eb95EVfKfjNgzkkP0CxRgbnZZGGh3yfJAh0KM7Qyo0&t=2e2045e2#52)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1006)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:411)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:252)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3286)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:808)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:868)
... 13 more
JavaScriptException value = Sys.ParameterCountException: Sys.ParameterCountException: Parameter count mismatch.
== CALLING JAVASCRIPT ==
function Function$emptyMethod() {
if (arguments.length !== 0) {
throw Error.parameterCount();
}
}
======= EXCEPTION END ========
问题 我应该在这个java程序中启用JS引擎(如何)?