Keys.TAB 不适用于 Selenium HTMLUnitDriver

发布于 2025-01-03 08:13:29 字数 539 浏览 3 评论 0原文

我们在项目中使用 HTMLUnitDriver。我们正在使用最新的 Selenium 2.18.0 版本。 我正在尝试使用 Keys.TAB 模拟 TAB 按键 (org.openqa.selenium.Keys) 将光标从用户名字段移动到 密码字段如下:

objWebDriver.findElement(By.id("username")).sendKeys(Keys.TAB); 
//Verify that focus is set to password text box. 
assertEquals(objWebDriver.findElement(By.id("password")), 
objWebDriver.switchTo().activeElement()); //Test fails here saying the 
focus is still on Username field 

但是,相同的代码在 FirefoxDriver 上运行良好。

如果有人对此有任何想法或使用模拟 TAB 键按下 HTMLUnitDriver,请告诉我。

We are using HTMLUnitDriver in our project. We are using the latest
version of Selenium 2.18.0.
I'm trying to simulate TAB key press using Keys.TAB
(org.openqa.selenium.Keys) to move the cursor from Username field to
password field as follows:

objWebDriver.findElement(By.id("username")).sendKeys(Keys.TAB); 
//Verify that focus is set to password text box. 
assertEquals(objWebDriver.findElement(By.id("password")), 
objWebDriver.switchTo().activeElement()); //Test fails here saying the 
focus is still on Username field 

But, the same code works fine on FirefoxDriver.

If anybody has any idea on this or on simulating TAB key press using
HTMLUnitDriver, please let me know.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文