有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

htmlunit java更改输入文本

我用它。 如果文本输入没有“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) 个答案

  1. # 1 楼答案

    HtmlInput intputBox = (HtmlInput)portfolios.getHtmlElementById('id');
    
    intputBox.setValueAttribute("text");
    
  2. # 2 楼答案

    {a1}有帮助吗