HtmlForm form = page.getForms().get(0); HtmlTextArea textArea = form.getTextAreaByName("scandata"); HtmlSubmitInput button = form.getInputByValue("Submit"); HtmlPage res = button.click(); int input_length = page.getByXPath("//input").size(); int tries = 5; while (tries > 0 && input_length < 12) { //you can change number of tries and condition according to your need tries--; synchronized (page) { page.wait(2000); //wait } input_length = page.getByXPath("//input").size(); //input length is example of condtion }
HtmlForm form = page.getForms().get(0); HtmlTextArea textArea = form.getTextAreaByName("scandata"); HtmlSubmitInput button = form.getInputByValue("Submit"); HtmlPage res = button.click(); int input_length = page.getByXPath("//input").size(); int tries = 5; while (tries > 0 && input_length < 12) { //you can change number of tries and condition according to your need tries--; synchronized (page) { page.wait(2000); //wait } input_length = page.getByXPath("//input").size(); //input length is example of condtion }
LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog"); java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF); java.util.logging.Logger.getLogger("org.apache.commons.httpclient").setLevel(Level.OFF); WebClient client = new WebClient(BrowserVersion.CHROME); client.getOptions().setJavaScriptEnabled(true); client.getOptions().setThrowExceptionOnScriptError(false); client.getOptions().setThrowExceptionOnFailingStatusCode(false); String url = "http://lsa.colorado.edu/cgi-bin/LSA-pairwise.html"; final HtmlPage page = client.getPage(url); HtmlForm htmlForm = page.getForms().get(0); HtmlTextArea txtA = htmlForm.getTextAreaByName("txt1"); txtA.setText("hello"); HtmlSubmitInput submitBt = htmlForm.getInputByValue("Submit Texts"); // change the form action attribute to the correct one htmlForm.setAttribute("action", "http://lsa.colorado.edu/cgi-bin/LSA-pairwise-x.html"); HtmlPage page2 = submitBt.click(); System.out.println(page2.asText());
HtmlPage page = story.j.createWebClient().getPage(b1, a.getUrlName()); HtmlForm form = page.getFormByName("config"); HtmlTextArea text = form.getTextAreaByName("_.mainScript"); assertEquals("echo 'first script'", text.getText()); text.setText("echo 'second script'");