htmlunit java更改输入文本

时间:2011-03-10 14:15:50

标签: java htmlunit

我使用htmlunit。 如果没有属性'value',我如何设置文本输入的值?

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

我尝试了这个,但没有尝试

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

请帮忙!

2 个答案:

答案 0 :(得分:8)

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

intputBox.setValueAttribute("text");

答案 1 :(得分:0)

相关问题