使用UIAutomation禁用iOS模拟器的硬件键盘 [英] Disable Hardware Keyboard for iOS Simulator using UIAutomation

查看:121
本文介绍了使用UIAutomation禁用iOS模拟器的硬件键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用UIAutomation在iOS模拟器中进行一些自动化测试.

I'm doing some automated tests in the iOS simulator using UIAutomation.

在Xcode 6中,iOS模拟器的键盘行为已更改,使其类似于真实设备,现在有了一个菜单项以将Mac的键盘连接/断开与模拟器的连接:硬件>键盘>连接硬件键盘.

In Xcode 6, the iOS simulator's keyboard behavior changed to be similar to a real device, and now there is a menu item to connect/disconnect your Mac's keyboard to the simulator: Hardware > Keyboard > Connect Hardware Keyboard.

我不介意,但是连接Mac键盘时会发生什么,就是模拟器将不再显示软件键盘.当您使用UIAutomation运行测试脚本时,即使将文本字段设置为第一响应者,UIATarget.localTarget().frontMostApp().keyboard().typeString("myString");之类的调用也会失败,因为没有出现键盘.

I don't mind this, but what happens when your Mac's keyboard is connected is that the simulator will no longer show the software keyboard. When you run a test script with UIAutomation, calls like UIATarget.localTarget().frontMostApp().keyboard().typeString("myString"); will fail because the keyboard doesn't appear, even when you've made a text field the first responder.

这很烦人,因为如果我在模拟器中进行任何手动测试,则需要记住在运行任何UIAutomation测试之前先禁用硬件键盘,否则它们都将失败.

This is annoying, because if I do any manual testing in the simulator, I will need to remember to disable the hardware keyboard before I run any of my UIAutomation tests, or they will all fail.

是否可以从UIAutomation JS脚本中检查硬件键盘设置并禁用它们?或者,在执行UIAutomation脚本之前,可以通过任何方式从命令行执行此操作?

Is there any way, from within a UIAutomation JS script, to check hardware keyboard settings and disable them? Or, any way to do this from the command line, prior to executing the UIAutomation script?

推荐答案

如果我正确理解了您的问题,则需要采用防弹方式输入文本.我只是使用setValue.像这样:UIATarget.localTarget().frontMostApp().textFields().Login.setValue('sofa');

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');

这篇关于使用UIAutomation禁用iOS模拟器的硬件键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆