【问题标题】:Appium 3.4.1 sendKey() not working with Android 4.4.2Appium 3.4.1 sendKey() 不适用于 Android 4.4.2
【发布时间】:2016-07-29 10:49:57
【问题描述】:

我正在使用 Appium 3.4.1、Android v4.4.2 和 Java 对 Android 应用进行自动化测试。我被卡住了向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");

【问题讨论】:

  • 你能分享你试过的代码吗
  • @nullpointer 感谢您的回复!!!! WebElement element=driver.findElement(By.id("com.intellih.mobile:id/edt_caloriesBurned_workout_add_exercise_MS")); element.clear(); element.click(); element=driver.findElement(By.id("com.intellih.mobile:id/edt_caloriesBurned_workout_add_exercise_MS")); element.sendKeys("55");
  • 在定义了element 之后将System.out.println(element.getAttribute("className") ) 添加到您的代码中会显示什么?
  • 在控制台上运行System.out.println(element.getAttribute("className") )时显示android.widget.EditText

标签: java android webdriver appium appium-ios


【解决方案1】:

点击该字段,然后运行下面的命令

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

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

【讨论】:

    猜你喜欢
    • 2016-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-04
    • 2017-08-20
    • 2016-09-08
    相关资源
    最近更新 更多