selenium - UI自动化——iOS按回车键
问题描述
我正在尝试在搜索文本时自动按下 ENTER 键
public void pressEnter() {
((IOSDriver) driver).getKeyboard().sendKeys(Keys.RETURN);
}
尝试自动按 Enter 键时出现此错误。这里有什么问题?这曾经奏效。我也试过 Keys.ENTER ,它给出了同样的错误。
java客户端版本:6.0.0
org.openqa.selenium.UnsupportedCommandException: sendKeysToActiveElement
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'DESKTOP-JPLMVQR', ip: 'my.ip.address.here', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_152-release'
Driver info: driver.version: IOSDriver
at org.openqa.selenium.remote.http.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:218)
at org.openqa.selenium.remote.http.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:117)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:152)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:218)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:35)
at org.openqa.selenium.remote.RemoteKeyboard.sendKeys(RemoteKeyboard.java:38)
at com.example.base.BaseTest.pressEnter(BaseTest.java:98)
at com.example.tests.SearchTests.verifySearch_RedirectToDetail(SearchTests.java:97)
解决方案
根据您的要求使用此代码更改,而不是 Done 像这样使用 Enter
IOSDriver<WebElement> AD= (IOSDriver) 驱动程序;
AD.hideKeyboard("PRESS_KEY", "完成");
推荐阅读
- c++ - 一维数组和三维数组使用一个模板
- angular - 尝试使用 webpack 构建 angular4 旧项目但失败
- c++ - 调整窗口大小时出现奇怪的伪影
- swift - 按顺序执行文本转语音
- javascript - 在javascript中将签名字段添加到pdf
- kotlin - org.springframework.data.mapping.MappingException 与 Kotlin 和密封类
- json - 尽管请求 JSON,Dynamic 365 API 仅返回 XML
- java - Windows 上的 Java 编译器不会创建可执行文件,只有 .class
- javascript - 如何在一定量的反应后使反应消失?
- node.js - 如何在我的 Flutter 应用程序中获取服务器发送事件?