How to trigger Done button on keyboard?

1,693 views
Skip to first unread message

Geoff Buesing

unread,
Jul 27, 2011, 7:13:01 PM7/27/11
to KIF iOS Automated Testing Framework
I've got KIF entering data into UITextFields successfully, but I can't
figure out how to trigger the Done button on the keyboard.

I tried fishing around for an accessibility label like @"Next" or
@"Done", but no luck.

Can anyone help?

Thanks!

Jim Puls

unread,
Jul 27, 2011, 7:24:07 PM7/27/11
to kif-fr...@googlegroups.com
I just clicked on the "Next"-labeled return key in my app in the simulator and the accessibility inspector told me its label was "next". Telling KIF to tap the view with accessibility label "next" (case sensitive) worked for me.

What label do you get if you check the accessibility inspector on the keyboard key?

-> jp

Geoff Buesing

unread,
Jul 28, 2011, 3:12:11 PM7/28/11
to kif-fr...@googlegroups.com
Aha -- thanks -- I get "done" in the accessibility inspector.

For some reason I was able to run my KIF tests on my work machine
without enabling the accessibility inspector, so I had no idea this
feature existed (on my home machine, KIF forced me to enable it to
continue.)

So, problem solved, but possibly there's a bug in KIFTestController
_isAccessibilityInspectorEnabled if I never got an exception running
without it. I'll check my work machine when I get a chance.

Jim Puls

unread,
Jul 28, 2011, 5:45:54 PM7/28/11
to kif-fr...@googlegroups.com
I'm a little unclear on what the simulator actually does with respect to the accessibility inspector. Before we added that check, we would have varied successes and failures running KIF test suites with the accessibility inspector turned off.

It's as if there's a disconnect and accessibility can be turned on without toggling the inspector in the Settings app.

-> jp

Eric Firestone

unread,
Jul 28, 2011, 5:49:50 PM7/28/11
to kif-fr...@googlegroups.com
There's a bit of black magic here. The flags for whether accessibility is enabled and whether the accessibility inspector are visible are actually separate, but the setting in the Settings app toggles both...sometimes. I believe all the values it toggles are in "~/Library/Application Support/iPhone Simulator/4.3.2/Library/Preferences/com.apple.Accessibility.plist", but I haven't done enough testing to figure out quite what does what. In our experience we've definitely seen cases where the accessibility bit is still on and the views are accessible without the inspector being visible, but I think this may actually be a bug that they're out of sync. If someone figures out what exactly needs to be done, we could potentially have KIF detect that it's in the sim and modify that file on disk to be set to the right thing.

Geoff Buesing

unread,
Jul 29, 2011, 4:04:18 PM7/29/11
to kif-fr...@googlegroups.com
Regarding KIF tests running without the Accessibility Inspector being enabled:

I checked Accessibility.plist on my work machine, which had the
Accessibility Inspector setting set to OFF (4.3.2 simulator; I'd never
before switched this on) and runs KIF tests fine without it, and I saw
just these two keys:

AccessibilityEnabled: YES
ApplicationAccessibilityEnabled: YES

I then turned on the Accessibility Inspector setting, and saw these
additional keys appear in the plist (along with values for
ScreenCurtain and VoiceOver):

AXInspector.enabled: YES (changes when I open/close Accessibility
Inspector window)
AXInspector.frame: (frame)
AXInspectorEnabled: YES

If I turn the setting back off again, these additional keys persist in
the plist. This time, when I try to run my KIF tests, I get the
exception that the Accessibility Inspector needs to be enabled.

Now from here, if I manually change ApplicationAccessibilityEnabled in
the plist to YES, my tests run fine, even though the Accessibility
Inspector isn't being displayed in the simulator.

As to KIF's black magic accessibility check, I'm not sure if this
could be improved further -- maybe it works as well as it needs to,
given that it throws an exception if ApplicationAccessibilityEnabled
is set to NO.

However, you might consider adding a step to the setup process in the
README to enable the Accessibility Inspector setting.

Reply all
Reply to author
Forward
0 new messages