0

我正在使用 Appium 3.4.1、Android v4.4.2 和 Java 对 Android App 进行自动化测试。我被卡住了向editText框发送值,该框在关注字段时激活数字键盘。但是,当我清除该字段时它起作用,当我单击字段时它起作用,但是当我将密钥发送到字段时它不起作用。它将值键入其他字段。我已经根据以下链接尝试了所有可能的方法。此外,多个屏幕上的某些字段在聚焦时打开数字键盘,并且 sendkeys 方法适用于这些字段。

有什么方法可以让我们使用 android 键盘使用 Appium 在字段中输入值

  1. https://discuss.appium.io/t/android-sendkeys-function-clicks-taps-random-elements-in-the-page-but-does-not-enter-text-in-the-edittext-element/ 2095
  2. https://discuss.appium.io/t/appium-1-3-3-sendkeys-not-working-properly/2074

我将不胜感激您对此的投入。

代码 :

WebElement element=driver.findElement(By.id("com.intellih.mobile:id/edt_caloriesBurned_work‌​out_add_exercise_MS")); 
element.clear(); 
element.click(); 
element=driver.findElement(By.id("com.intellih.mobile:id/edt_caloriesBurned_work‌​out_add_exercise_MS")); 
element.sendKeys("55");
4

1 回答 1

0

单击该字段,然后运行以下命令

Runtime.getRuntime().exec("adb shell 输入keyevent KEYCODE_NUMPAD_5";

这将在字段中键入 5,您可以在同一字段上运行多个命令。

于 2016-04-20T08:55:55.140 回答