Detox _ Failed to type string because keyboard was not shown on screen

自作多情 提交于 2019-12-04 08:09:25

You should run

await element(by.id('LoginPage-phoneInput')).tap();

before

await element(by.id('LoginPage-phoneInput')).typeText('<someNumber>')

please checkout here: https://github.com/wix/detox/blob/master/docs/APIRef.ActionsOnElement.md

on typeText() method

Note: Make sure hardware keyboard is disconnected. Otherwise, Detox may fail when attempting to type text.

To make sure hardware keyboard is disconnected, open the simulator from Xcode and make sure Hardware -> Keyboard -> Connect Hardware Keyboard is deselected (or press ⇧⌘K).

I tried the various solutions listed here, but no avail.

What worked consistently for me was:

  • Tap on any text field in your app
  • Simulator > Hardware > Keyboard > Toggle Software Keyboard (⌘K)

The reason this works is because it automatically toggles the builtin keyboard on anytime a text field element is tapped, which is a mandatory prerequisite when calling typeText.

I've added a pull request to update the documentation which has now been approved.

I wasn't able to get get the software keyboard work consistently but .replaceText() did work pretty well for me. waitFor() was also very useful.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!