Reputation: 1073
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
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