gpt4 book ai didi

java - 如何为 HtmlUnit 中没有 value 属性的文本字段提供值?

转载 作者:行者123 更新时间:2023-12-01 09:59:34 24 4
gpt4 key购买 nike

下面的 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com