kif-framework / KIF

Keep It Functional - An iOS Functional Testing Framework
Other
6.21k stars 912 forks source link

tappablePointInRect failing for UISearchBar #399

Closed jrwagz closed 10 years ago

jrwagz commented 10 years ago

We are using [tester tapViewWithAccessibilityLabel:@"Search"]; to select a UISearchBar that is present in a UITableViewController.

However, recently this method has started to fail with the following error View is not tappable.

I did some digging and found where the problem appears to be happening, I'm just not really sure what the right fix is, that's where you guys come in.

First of all, here is a screenshot of the view we are talking about: ios simulator screen shot may 21 2014 10 07 40 pm

While in this view I issue the [tester tapViewWithAccessibilityLabel:@"Search"]; command, and I stepped down through to where tappablePointInRect (https://github.com/kif-framework/KIF/blob/master/Additions/UIView-KIFAdditions.m#L528) gets called on the frame of the UIAccessibilityElement that was successfully found. the CGPoint that get's returned is NaN, NaN which is what I believe is causing the problem.

I did some further digging and found out that the very first line of that method (https://github.com/kif-framework/KIF/blob/master/Additions/UIView-KIFAdditions.m#L531) calls CGRect frame = [self.window convertRect:rect fromView:self]; but after inspecting this, self.window is nil, and therefore the returned frame is 0,0,0,0

screen shot 2014-05-21 at 10 06 29 pm

Should the window property of a UISearchBar be nil? This appears to be what is causing the problem. Any thoughts or suggestions are appreciated.

jrwagz commented 10 years ago

It looks like this is because we are actually grabbing the search view from a previous view (which is why it is removed from the view when we try to tap it).

This is an error in our test, not KIF :)