【发布时间】:2016-07-29 10:49:57
【问题描述】:
我正在使用 Appium 3.4.1、Android v4.4.2 和 Java 对 Android 应用进行自动化测试。我被卡住了向editText框发送值,该框在关注字段时激活数字键盘。但是,当我清除该字段时它起作用,当我单击字段时它起作用,但是当我将密钥发送到字段时它不起作用。它将值键入其他字段。我已经根据以下链接尝试了所有可能的方法。此外,多个屏幕上的某些字段在聚焦时打开数字键盘,并且 sendkeys 方法适用于这些字段。
有什么方法可以让我们使用 Android 键盘在 Appium 中输入值
- 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
- 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_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");
【问题讨论】:
-
你能分享你试过的代码吗
-
@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