views:

32

answers:

1

Hi All, I have an iPhone app and I want to get a list of co-ords that are clickable by a user. I want to automate testing and have a client app click around on screen but just choosing random coords isn't ideal so a list of coords that are definitely clickable would be much better.

So far I have this the view passed in is top level window:

getSubViewsCoords:(UIView *)view {

iAppDelegate* appDelegate = [[UIApplication sharedApplication] delegate];


for (UIView *tempView in [view subviews]) {

 // check if view responds to touch i.e. is an interactive view.

 // go up through responder chain
 // check if it reacts
 // if it does then add to the gorilla's list

 UIView *responderObj = tempView;

 while (responderObj = [responderObj nextResponder]) {

  if([responderObj respondsToSelector:@selector(touchesBegan:withEvent:)]){

   // get xy etc and add to instance var
   //then recall this function

   // convert to top level windows co-ordinate system.
   CGRect viewRect = [tempView convertRect:[tempView bounds] toView:nil];

   clickableAreas = [clickableAreas stringByAppendingString: NSStringFromCGRect(viewRect)];
   clickableAreas = [clickableAreas stringByAppendingString: @"\n"];

   break;


  }

 }

 [self getSubViewsCoords:tempView];

Is this the correct way to go about it? Is there an easier way to get this information?

Thanks in advance for your help.

+1  A: 

If you haven't already read it, you'll probably find this article helpful, Automated user interface testing on the iPhone.

Vincent Gable