0

i am using HTMLUNit to set the value of a form hidden element as below.

HtmlHiddenInput hidden  = (HtmlHiddenInput) page.get("someid");
            hidden.setValueAttribute(seriesName);

But this does not work as expected and throw an castException.

I have div element like follows

<div class="myclass">
<form:hidden id="someid" htmlEscape="true"/>
</div>

How can i set the value for that hidden form id using HTMLUNIT. Thanks.

rakeeee
  • 973
  • 4
  • 19
  • 44

1 Answers1

1

You don't need to use HtmlHiddenInput. If you are getting a cast exception, use a base object, as DomElement.

DomElement myInput = page.getElementById("someid");
myInput.setAttribute("value", seriesName);

So with any html dom element, the value attribute will be set to seriesName

Aron Bordin
  • 436
  • 4
  • 13