使用 Selenium 使用 sendKeys() 时,大写字母被重新排列/交换

发布于 2025-01-19 08:46:52 字数 210 浏览 2 评论 0原文

我使用硒和Chromedriver遇到了问题。 使用sendkeys()带有首都的方法时,字母会重新排列。 例如,我使用:

element.sendKeys("ABCD")`

但是在运行时,它发送了“ CDAB”字符串。

到目前为止,我使用这种方法,它只会发生在首都。

有人知道原因吗?

I've faced a problem using Selenium and chromedriver.
When using sendKeys() method with capitals, letters are rearranged.
For example, I use:

element.sendKeys("ABCD")`

but in runtime it sends "CDAB" string.

As far I played with this method, it happens only with CAPITALS.

Does anyone know the reason why?

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

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

发布评论

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

评论(1

握住我的手 2025-01-26 08:46:52

元素的基于文本的 HTML 将有助于以更好的方式调试问题。

但是,始终建议将字符序列发送到任何 字段,您需要引入 WebDriver等待elementToBeClickable() 用于要渲染的元素 > 完全可以使用以下解决方案:

new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("element_cssSelector"))).sendKeys("ABCD");

The text based HTML of the element would have been helpful to debug the issue in a better way.

However, it is always recommened that to send a character sequence to any <input> field you need to induce WebDriverWait to elementToBeClickable() for the element to render completely and you can use the following solution:

new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("element_cssSelector"))).sendKeys("ABCD");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文