how to confirm a NumberPicker after sending data w

2019-08-15 21:06发布

问题:

I write test automation for Android Native app. And I want to enter/send value to a NumberPicker, my code is below:

WebElement heightValue = appiumDriver.findElement(By.className("android.widget.NumberPicker"));
heightValue.sendKeys("180");
appiumDriver.findElement(By.id("com.kmp.connect.coach:id/buttonDefaultPositive")).click();

Problem is, I have to click confirm on native keyboard and then click OK button of my app, then value is set. But I can not interfere with native keyboard. I try InputMethodManager but I couldn't get context of the app. I want to somehow send "Done" to keyboard

I am using Appium with selenium

回答1:

This one interacts with native keyboard action key - enter(confirm):

driver.sendKeyEvent(66);