简体   繁体   中英

How can I disable/dismiss the keyboard on iOS with Appium

Is there anyway to dismiss the iPhone keyboard or disable it from popping up at all while Appium tests are being run?

driver.hideKeyboard() doesn't work, half the time a "DONE" or "RETURN" button isn't present and I can't just tap randomly on the screen because I can not guarantee that the code won't accidentally tap a link or active element.

I don't understand why it doesn't just function like on Android and just never display the keyboard when using driver.sendKeys().

I've noticed the same and did a workaround by doing it like an actual user and clicking on the hide keyboard button. You might want to add a check to only click if the element is visible to avoid trying to close the keyboard when it's not there.

driver.findElement(By.xpath("your_keyboard_close_button")).click();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM