Disable iOS Simulator 'Connect Hardware Keyboard' Programmatically

Disable Hardware Keyboard for iOS Simulator using UIAutomation

If I understood your question correctly, you need bulletproof way to enter text. I just use setValue for that. Like this: UIATarget.localTarget().frontMostApp().textFields().Login.setValue('sofa');

How to type an @ in iOS simulator using the hardware keyboard?

Sounds like it's your keyboard layout. Option + L renders ¬ on both macOS and iOS for me. If you have an American English keyboard layout you probably want Shift + 2. If you prefer to use the keyboard layout you're accustomed to you might need to configure it in the simulator.

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

The simulator's .plist file changed to add support for multiple simulators. The ConnectHardwareKeyboard boolean is now nested underneath the device's UDID. Luckily this UDID is also stored in the plist file. You can add this code using 'run script' under your UITest target's build phases.

Xcode 9 answer:

#grab the UDID from the plist
UDID=$(defaults read com.apple.iphonesimulator CurrentDeviceUDID)

#overwrite the existing value with false
#OR if the plist doesn't have that value add it in
/usr/libexec/PlistBuddy -c "Set :DevicePreferences:$UDID:ConnectHardwareKeyboard
false" ~/Library/Preferences/com.apple.iphonesimulator.plist
||
/usr/libexec/PlistBuddy -c "Add :DevicePreferences:$UDID:ConnectHardwareKeyboard
bool false" ~/Library/Preferences/com.apple.iphonesimulator.plist

Or you can use this other code to affect all simulators:

/usr/libexec/PlistBuddy -c "Print :DevicePreferences" ~/Library/Preferences/com.apple.iphonesimulator.plist | perl -lne 'print $1 if /^    (\S*) =/' | while read -r a; do /usr/libexec/PlistBuddy -c "Set :DevicePreferences:$a:ConnectHardwareKeyboard
false" ~/Library/Preferences/com.apple.iphonesimulator.plist || /usr/libexec/PlistBuddy -c "Add :DevicePreferences:$a:ConnectHardwareKeyboard
bool false" ~/Library/Preferences/com.apple.iphonesimulator.plist; done

how to disable ios simulator keyboard in xcode 12?

This should help:
driver.hideDeviceKeyboard();

See docs for details.



Related Topics



Leave a reply



Submit