This discussion is archived
0 Replies Latest reply: Nov 30, 2012 10:02 PM by 655260 RSS

HtmlUnit - setAttributeValue or setHiddenInputValue

655260 Newbie
Currently Being Moderated
Hello again. I can get the attribute value with this method:

-----

WebClient client = new WebClient();

HtmlPage page = client.getPage ("http://mydomain.com/welcome.jsp");

HtmlHiddenInput hidden = (HtmlHiddenInput) page.getElementByName("pagecodes");

System.out.println(hidden.getValueAttribute());

-----

The output = 12345

-----

Now I need to send this attribute value along with my next page request. The following method would work:

HtmlPage page = client.getPage ("http://mydomain.com/nextpage.jsp?pagecodes=12345");

-----

But the above method is cumbersome when submitting a large number of values. I am seeking a method like the following pseudocode:

-----

HtmlPage page = client.getPage ("http://mydomain.com/nextpage.jsp");

page.setHiddenInputValue("pagecodes") = 12345;

-----

Any suggestions are greatly appreciated.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points