IWebElement.SendKeys() 不完整

发布于 2024-12-18 00:06:24 字数 378 浏览 2 评论 0原文

我遇到的问题是 IWebElement.SendKeys() 没有填充我想要的整个输入字段。下面是代码示例:

...
IWebElement el1 = driver.FindElemenet(By.Id("el1Id"));
IWebElement el2 = driver.FindElemenet(By.Id("el2Id"));
el1.SendKeys("sometext");
el2.SendKeys("someothertext");
...

因此,有时,它不是用“sometext”填充 el1Id,而是用 el2Id 进行处理,而在 el1Id 中,它仅填充“somet”。大约 30% 的情况会发生这种情况,键入的字符数因情况而异。我使用的是火狐8.0

I'm experiencing the problem that IWebElement.SendKeys() does not fill entire input field that I'm aiming. Here is the code example:

...
IWebElement el1 = driver.FindElemenet(By.Id("el1Id"));
IWebElement el2 = driver.FindElemenet(By.Id("el2Id"));
el1.SendKeys("sometext");
el2.SendKeys("someothertext");
...

So, sometimes, instead of filling el1Id with "sometext", it proceeds with el2Id and in el1Id it is only filled "somet" for example. This is happening in like 30% of cases, number of typed characters differs from case to case. I'm using Firefox 8.0

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

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

发布评论

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

评论(1

如日中天 2024-12-25 00:06:24

如果您想更加稳健,只需在下一步之前添加等待即可。

类似:

await Task.Delay(1000);

或者

Thread.Sleep(1000);

这样就可以了。

If you want to be more robust just add a waiting before the next step.

Something like:

await Task.Delay(1000);

or

Thread.Sleep(1000);

That's will do the job.

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