下面的 HTML 元素是表单的一部分:
<input id="code" type="text" name="code" placeholder="Enter code here" autocomplete="off"/>
我想将一个字符串传递给该元素。我不知道如何传递没有 value 属性的字符串。
最佳答案
您可以尝试使用 setText()
方法将字符串传递给输入:
HtmlTextInput input = (HtmlTextInput) page.getElementById("code");
input.setText("your_text");
或type()
方法:
HtmlTextInput input = (HtmlTextInput) page.getElementById("code");
input.type("your_text");
关于java - 如何为 HtmlUnit 中没有 value 属性的文本字段提供值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36920639/