WebDriver 的 WebElement sendKeys() 方法不适用于输入字段

发布于 2025-01-06 16:28:53 字数 326 浏览 2 评论 0原文

我有一个如下所示的输入字段:

<input class="..." maxlength="..." title="..." size="..." value="..." name="..."/>

这看起来像一个文本输入字段,但没有类型属性。我正在尝试清除该字段的内容并在其中写入一些内容。

element.clear();
element.sendKeys("abc");

问题是这两种方法都不起作用。我问自己缺少的 type="text" 属性是否是问题所在。如果没有,为什么这不起作用?

I have an input field like the following:

<input class="..." maxlength="..." title="..." size="..." value="..." name="..."/>

This looks like an text input field, but there is no type-attribute. I am trying to clear the content of the field and write something into it.

element.clear();
element.sendKeys("abc");

The problem is that both methods don't work. I am asking myself if the missing type="text"-attribute is the problem or not. If not, why does this not work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心不设防 2025-01-13 16:28:54

尝试在 clear() 之前对该元素使用 click() sendKeys()

Try using a click() on that element before clear() & sendKeys().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文