WebDriver 的 WebElement sendKeys() 方法不适用于输入字段
我有一个如下所示的输入字段:
<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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在
clear()
之前对该元素使用click()
sendKeys()
。Try using a
click()
on that element beforeclear()
&sendKeys()
.