Dav*_*ave 5 selenium browser-automation selenium-webdriver
据我所知,有两种使用 Selenium 打字的方法:
new Actions(webDriver).sendKeys("text to send").perform();
webElement.sendKeys("text to send");
Run Code Online (Sandbox Code Playgroud)
该Actions方法似乎是复制用户键入的最自然的方式,因为按键被发送到浏览器想要的任何地方(我相信正在幕后使用名为 sendKeysToActiveElement 的方法)。然而,许多教程指导测试人员使用该WebElement方法(这实际上是使用 SafariDriver 时的唯一选择),我认为因为它更简单。
该Actions方法实际上是更好地模拟用户交互,还是我应该WebElement为了方便而使用该方法?
公共操作 sendKeys(java.lang.CharSequence... 键)
将键发送到活动元素。这与在活动元素上调用 WebElement.sendKeys(CharSequence...) 有两个不同之处:
有关更多信息,您可以参考此链接:https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/interactions/Actions.html#sendKeys-java.lang.CharSequence...-
| 归档时间: |
|
| 查看次数: |
13697 次 |
| 最近记录: |