Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htmlunit java change input text

Tags:

java

htmlunit

I use htmlunit. How i can set value of text input if it does not have an attribute 'value' ?

<input type="text" onkeypress="test();" id="id" name="name" class="ttt">

I tried this, but nothing

    ((HtmlTextInput) portfolios.getHtmlElementById("id")).setText("text");
    ((HtmlInput) portfolios.getHtmlElementById("id")).setTextContent("text");
    ((HtmlInput) portfolios.getHtmlElementById("id")).setAttribute("value", "text");

Please help!

like image 786
jim Avatar asked Mar 10 '11 14:03

jim


1 Answers

HtmlInput intputBox = (HtmlInput)portfolios.getHtmlElementById('id');

intputBox.setValueAttribute("text");
like image 191
Nosherwan Adil Avatar answered Nov 02 '22 13:11

Nosherwan Adil