Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force Software Keyboard in iOS Simulator for XCUITest

I am using XCUITest to test UI behaviour when the keyboard is present - for example, if content properly moves up when the keyboard appears.

For some reason, the iOS simulator insists on regularly just disabling the software keyboard. Sometimes while the simulator is restarted, but sometimes even just when switching textfields in the middle of a test.

Is there a way to always force the software keyboard in the simulator? e.g. a command line argument or a property on XCUIDevice? I am running these tests on a CI, so manually enabling the software keyboard in the simulator is not an option.

like image 689
BlackWolf Avatar asked Mar 27 '19 15:03

BlackWolf


People also ask

What are the system requirements for xcuitest?

Apple's XCUITest library is only available on iOS simulators and devices that are running iOS 9.3 or higher. A Mac computer with macOS 10.11 or 10.12 is required. Xcode 7 or higher is required. The XCUITest driver was available in Appium starting with Appium 1.6.

How to connect a keyboard to the iOS simulator?

Select the iOS simulator window by click it. Click the simulator menu Hardware —> Keyboard, check the Connect Hardware Keyboard sub-menu, and then uncheck it at once. Now the keyboard will be prompted automatically when you click the text field or text view UI component in the iOS simulator. 2.

How to fix iOS simulator keyboard hidden issue?

Click the simulator menu Hardware —> Keyboard, check the Connect Hardware Keyboard sub-menu, and then uncheck it at once. Now the keyboard will be prompted automatically when you click the text field or text view UI component in the iOS simulator. 2. Fix iOS Simulator Keyboard Hidden Issue Method Two.

How does xcuitest work with Appium?

Appium's XCUITest driver manages WDA as a subprocess opaque to the Appium user, proxies commands to/from WDA, and provides a host of additional functionality (like simulator management and other methods, for example). Development of the XCUITest driver happens at the appium-xcuitest-driver repo. In addition to Appium's general requirements:


1 Answers

I added a prescript in Xcode. It writes defaults ConnectHardwareKeyboard NO to ~/Library/Preferences/com.apple.iphonesimulator.plist file AND quits the Simulator. Quitting simulator is important because when the tests relaunch the simulator, only then it takes into account the defaults value we wrote.

enter image description here

like image 184
Hasaan Ali Avatar answered Sep 27 '22 16:09

Hasaan Ali