Is it possible to “toggle software keyboard” via the code in UI test?

前端 未结 7 628
时光取名叫无心
时光取名叫无心 2020-12-24 03:25

I have UI tests which testing login functionality (and uses it to test other stuff), but sometimes when focus is changed from one field to another - the keyboard hides, and

7条回答
  •  旧巷少年郎
    2020-12-24 04:17

    inspired by real_kappa_guy s answer above, I managed to do it without restarting the simulator by checking if the keyboard is enabled and then running apple script to send the keyboard shortcut Cmd-shift-k (need to be added to pre-test action):

    if test `/usr/libexec/PlistBuddy -c "Print DevicePreferences:${TARGET_DEVICE_IDENTIFIER}:ConnectHardwareKeyboard" ~/Library/Preferences/com.apple.iphonesimulator.plist` == true; then 
    osascript <

提交回复
热议问题