【发布时间】:2018-03-23 22:22:25
【问题描述】:
我正在学习 selenium,当我在探索与键盘和鼠标的交互主题时,我发现了这段代码。 在 Robot 类的帮助下,执行 Enter :
Robot r=new Robot();
r.keyPress(KeyEvent.VK_ENTER);
借助 Actions 类,执行 Enter :
Actions action = new Actions(driver);
action.sendKeys(Keys.ENTER).build().perform();
为什么我们需要两个类来执行相同的操作? Robot 类和 Actions 类有什么区别? TIA。
【问题讨论】:
-
Selenium 的
Actions没有与标准库绑定,需要浏览器驱动程序。Robot存在于标准库中,不需要浏览器驱动程序。 -
@VinceEmigh : tnks 得到了如此简短而完整的解释:)
标签: java selenium selenium-webdriver action awtrobot