From: Ahmed A. <asa...@ya...> - 2017-03-30 23:02:13
|
Hi, You need to isolate a minimal case, please read http://htmlunit.sourceforge.net/submittingJSBugs.html Ahmed From: jp_listero <jpl...@gm...> To: htm...@li... Sent: Thursday, March 30, 2017 8:18 PM Subject: [Htmlunit-user] click doesn't work Hi there, I am spidering a web page ... but click() doesnt work, or doesn't navigate ... Any clue what could be the issue ? I'm using 2.25 version this my code: @Testpublic String getFacturas() 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("https:// wse-prod.antel.com.uy/ ConsultaCFE/form/ consultarCuenta.jsf"); // 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(" 16000455000231"); // 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; } best regards ! ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________ Htmlunit-user mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |