8

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!

skaffman
  • 398,947
  • 96
  • 818
  • 769
jim
  • 81
  • 1
  • 1
  • 2

2 Answers2

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

intputBox.setValueAttribute("text");
Mohamed Taher Alrefaie
  • 15,698
  • 9
  • 48
  • 66
Nosherwan Adil
  • 141
  • 1
  • 5
-1

Does HtmlInput.setValueAttribute() help?

David Lantos
  • 670
  • 4
  • 8