Unable to access segments in segmented controller

503 views
Skip to first unread message

Christopher Campbell

unread,
Aug 22, 2011, 6:38:00 PM8/22/11
to KIF iOS Automated Testing Framework
Hi,

New to KIF, and I'm loving it. Thanks for putting this out there.

Question:
I'm attempting to execute stepToTapViewWithAccessibilityLabel on a
segment in a segmented controller. The control's attributes are
correctly set (i.e. titles, and "user interaction" has been enabled).

When I run the test I get the following error:
FAILING ERROR: Error Domain=KIFTest Code=0 "The step timed out after
30.00 seconds." UserInfo=0x5c6d730 {NSUnderlyingError=0x5c83bb0 "View
with accessibility label "Artists" is not enabled for interaction",
NSLocalizedDescription=The step timed out after 30.00 seconds.}

I've confirmed that the element is accessible and is indeed exposed by
issuing stepToWaitForViewWithAccessibilityLabel on the segment in
question.

Any thoughts as to what may be going on?

Kind regards,
Christopher Campbell

Eric Firestone

unread,
Aug 22, 2011, 6:42:27 PM8/22/11
to kif-fr...@googlegroups.com
Segmented controls are a bit funky and use a private child view class called UISegment in order to represent the different segments. We handle this in some cases (see UIView-KIFAdditions, -isTappableWithHitTestResultView:), but perhaps we need to special case the "interaction is enabled" check as well. Give me a sec and I'll take a look.

Eric Firestone

unread,
Aug 22, 2011, 7:09:47 PM8/22/11
to kif-fr...@googlegroups.com
I'm not having any trouble. A couple points:
 - Is this a UISegmentedControl or a UITabBarController? Both work fine for me, but:
   - For segmented controls, the labels include the ordinal in the label following a comma, such as "Birds, 1 of 2".
   - For tab bar controllers, there is a bug with setting the accessibility label on tabs which I filed with Apple and which is still open. You should still be able to use the title as the accessibility label without a problem though.
 - Are you using the latest version of KIF? I noticed that you have a 30s timeout, which was the old default. We did fix some things surrounding segmented controls about a month ago.
 - If none of this helps, would it be possible to get a sample app?

Christopher Campbell

unread,
Aug 22, 2011, 7:37:41 PM8/22/11
to KIF iOS Automated Testing Framework
Oh man thanks so much Eric.

You totally nailed it by suggesting I include the ordinal/comma in the
label. It works!

Thanks again for your help and for such a great tool.

Regards,
Christopher Campbell
Reply all
Reply to author
Forward
0 new messages