Estoy intentando clcik un botón en un sitio web usando HTMLUNIT seguí este tutorial http://htmlunit.sourceforge.net/gettingStarted.html pero requiere un nombre de formulario. El sitio web que trato de hacer tiene esta fuente de la página.HTMLUNIT getformbyname sin nombre de formulario especificado en el sitio web
<form method="post" action="doDelete">
Are you sure you want to delete 'Apple?'?
<input name="Submit" value="Yes" class="submit-button" type="submit" />
</form>
estoy tratando de hacer clic en el cuadro de la validación botón "Sí" en la página web. (Eliminar Valdation) Como se puede ver no hay ningún nombre formulario suministrado. Aquí está mi código.
final WebClient webClient = new WebClient();
final HtmlPage page1 = webClient.getPage("http://ma.some-site.com:8080/user/mike/delete");
List<HtmlForm> formlist = (List<HtmlForm>) page1.getForms();
System.out.println(formlist.toString());
final HtmlForm form = page1.getFormByName("myform"); <---Problem here
final HtmlSubmitInput button = form.getInputByName("Submit");
button.click();
webClient.closeAllWindows();
He intentado esto, pero no funciona
final HtmlForm form = page1.getFormByName(formlist.get(1).getLocalName());
Creo que se puede utilizar XPath para encontrar el nombre del formulario?
¡Muchas gracias! ¡Te marqué como respuesta! –
Gracias, bienvenido :) –
en esto, ¿cómo agregaría si acción en forma action =/dialog/oauth/read – jackyesind