rakeeee
rakeeee

Reputation: 1073

Set the value for an hidden form element

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.

Upvotes: 0

Views: 527

Answers (1)

Aron Bordin
Aron Bordin

Reputation: 436

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

Upvotes: 1

Related Questions