Appium Android SendKey 不工作

Appium Android SendKey not working

我正在尝试使用 Appium Java 客户端在 testdroid 服务器上自动化我的 android 应用程序测试。在 AndroidElement 上使用 element.sendKeys 时出现无法定位元素的异常。

AndroidElement element = wd.findElement(By.xpath("//android.widget.LinearLayout[1]"
               + "/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]"
               + "/android.widget.RelativeLayout[1]/android.widget.LinearLayout[1]"
               + "/android.widget.EditText[1]"));
element.click();
wd.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
element.sendKeys("Hello World");

在上面的代码中 element.sendKeys 抛出异常

An element could not be located

看起来是 "hinted text issue" 的 sendKey 但不确定。

请给我建议解决方案。

对于 android,您应该将能力 "unicodeKeyboard" 设置为 "true"。也不要忘记重置

capabilities.setCapability("unicodeKeyboard", "true");
capabilities.setCapability("resetKeyboard", "true");

参考http://appium.io/slate/en/v1.3.4/?ruby#android-only