我使用htmlunit。 如何設置文本輸入的值,如果它沒有屬性「值」?htmlunit java更改輸入文本
<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");
請幫幫忙!
「但沒有什麼」是什麼意思? – skaffman 2011-03-10 14:51:52
即使您沒有爲html文本輸入專門添加值,您也應該可以設置'value'屬性。你面臨的錯誤是什麼? – Nishan 2011-03-10 16:04:13