Java Htmlunit-click()不';行不通

Java Htmlunit-click()不';行不通,java,htmlunit,Java,Htmlunit,我正在浏览一个网页。。。但是click()不起作用,或者无法导航。。。 有什么线索吗?我使用的是2.25版本 您可以看到代码中的所有细节,非常感谢您 这是我的代码: @Test public String xxx() throws Exception { try (final WebClient webClient = new WebClient(BrowserVersion.getDefault())) { webClient.setJavaScri

我正在浏览一个网页。。。但是click()不起作用,或者无法导航。。。 有什么线索吗?我使用的是2.25版本

您可以看到代码中的所有细节,非常感谢您

这是我的代码:

@Test
public String xxx() throws Exception {

        try (final WebClient webClient = new WebClient(BrowserVersion.getDefault())) {

            webClient.setJavaScriptTimeout(15000);
            webClient.getOptions().setThrowExceptionOnScriptError(false);
            webClient.getOptions().setJavaScriptEnabled(false);
            webClient.waitForBackgroundJavaScript(30000);
            webClient.getOptions().setActiveXNative(true);
            webClient.getOptions().setAppletEnabled(true);
            webClient.getOptions().setCssEnabled(true);
            webClient.getOptions().setUseInsecureSSL(true);
            webClient.getOptions().setRedirectEnabled(true);

            // add to log variable
            //toLog.append(" contrato: ").append(numeroContrato);

            final HtmlPage consultaCuentaPage = webClient.getPage(url);

            // grab first form
            final HtmlForm consultarCuentaForm = consultaCuentaPage.getForms().get(0);

            // numero cuenta input
            final HtmlInput numeroCuentaInput = consultarCuentaForm.getInputByName("nroCuenta");

            // consultar button
            final HtmlInput consultarButton = consultarCuentaForm.getInputByName("commandConsultar");

            // Change the value of the text field
            numeroCuentaInput.setValueAttribute("1111");


            // Now submit the form by clicking the button and get back the second page.
            final HtmlPage consultaCuentaPage2 = consultarButton.click();

            LOG.info("time: " + consultaCuentaPage2.getWebResponse().getLoadTime());
            //  LOG.info("time: " + consultaCuentaPage2.getWebResponse().getContentAsString());

            //System.out.println(consultaCuentaPage2.asText());

            ////*[@id="form"]/div[1]/fieldset/table/tbody/tr[1]/td[1] 
            if (consultaCuentaPage2.getFirstByXPath("//*[@id=\"form\"]/div[1]/fieldset/table/tbody/tr[1]/td[1]") != null) {
                return ((HtmlTableDataCell)consultaCuentaPage2.getFirstByXPath("//*[@id=\"form\"]/div[1]/fieldset/table/tbody/tr[1]/td[1]")).asText();
            }       
        }
        return null;
    }
用这个解决用这个解决