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

前端 未结 7 612
时光取名叫无心
时光取名叫无心 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 <<EOD
      tell application "Simulator" to activate
      tell application "System Events"
          keystroke "K" using {command down, shift down}
      end tell
    EOD
    fi
    
    0 讨论(0)
提交回复
热议问题