使用UIAutomation禁用iOS模拟器的硬件键盘当我在xcode local上尝试此方法时,它可以工作,但是,XCUItest在CI上运行,并且在测试执行开始之前,我为此调用的键盘键盘配置了fastlane文件.但这会引发错误设置:条目,:DevicePreferences :: ConnectHardwareKeyboard ,不存在任何帮助将不胜感激解决方案经历了同样的问题.找到了一个简单的解决方案,在UI测试方案中添加了规定. 首先,这是使用Xcode打开的plist文件的图像.该文件位于〜/Library/Preferences/com.apple.iphonesimulator.plist 现在这是我添加到ui测试方案中的规范.阅读脚本中的注释以获取进一步的解释. killall Simulatordefaults write com.apple.iphonesimulator ConnectHardwareKeyboard -bool false 工作原理首先,模拟器被杀死.接下来,默认值"命令将键/值写入模拟器的plist.现在,当测试开始时,他们将启动模拟器,该模拟器将考虑我们在plist中编写的值.希望它也对您有用. :) I'm writing XCUITests for view has 2 UITextField and by defualt the simulator has hardware keyboard connected, hence the software one is not being presented.Is it possible to set some settings (maybe in schema?) to force-disable connecting hardware keyboard by the simulator before test runs.I went through few links but none seems to be helpful.iOS simulator - disable connect hardware keyboard programmaticallyDisable Hardware Keyboard for iOS Simulator using UIAutomationWhen i try this on xcode local it works but, XCUItest runs on CI and i configured fastlane file for this called enable keyboard script before Test execution starts.But it throws errorSet: Entry, ":DevicePreferences::ConnectHardwareKeyboard ", Does Not ExistAny help would be really appreciated 解决方案 Went through the same problem. Found a simple solution to add a prescript in the UI tests scheme.First, this is image of the plist file opened with Xcode. This is located at ~/Library/Preferences/com.apple.iphonesimulator.plistNow here is the prescript I added to my ui tests scheme. Read the comments in script for further explanation.killall Simulatordefaults write com.apple.iphonesimulator ConnectHardwareKeyboard -bool falseHow it worksFirst the simulator is killed. Next the "defaults" command writes the key/value into the simulators plist. Now when the tests start, they launch the simulator which takes into account the value we wrote in plist.Hope it works for you too. :) 这篇关于以编程方式禁用iOS模拟器“连接硬件键盘"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-30 08:42