10

I'm using Calabash to do some automated UI testing for my app, and I'm trying to touch some views which are embedded inside of a larger view, so I can't access their exact name to touch them directly.

So I'm trying to touch them using the relative center of the view they're embedded in, however, I'm just blindly adjusting my offset to try and hit these views without knowing if I'm getting farther or closer to the view.

So, my question, is there a way to show where a touch even occurred in the iOS simulator? I'm thinking something like a dot or some way to indicate that a touch occurred and where it occurred.

Any help is appreciated, thanks!

Bill L
  • 2,576
  • 4
  • 28
  • 55
  • I saw this post on the old google group about calabash-ios https://groups.google.com/forum/#!topic/calabash-ios/ybbhwfMJw7E about using parent keyword to go through nested views. I don't know if that can help in your case but doing something like that instead of hardcoding would be better. – Lasse Aug 26 '15 at 18:41
  • My problem is it appears that these "views" I'm trying to touch are all part of one singular view, not a bunch of nested views. It's a private library, so I can't look at the actual implementation, but when I look at the Debug View Heirarchy, the view in question is just one big view, it all appears and dissappears as one as I walk through the heirarchy. – Bill L Aug 26 '15 at 18:47
  • https://github.com/morizotter/TouchVisualizer – MCMatan Aug 26 '15 at 19:22

2 Answers2

17

defaults write com.apple.iphonesimulator ShowSingleTouches 1

Execute this command in terminal and restart the simulator

Sateesh Pasala
  • 772
  • 8
  • 15
0

It sounds like there are not embedded views, but just a single view that responds to touches in various locations.

The Calabash query language can find views that are embedded in other views.

In addition to visualizing the touch, you might try logging where the touches are occurring. The Briar iOS Example app has an example of how to do this. The gist is to create a UIWindow subclass, add a method to intercept the sendEvent: selector, log the touch point, and then call UIWindow's sendEvent:.

You can view device logs in Xcode's Device Window (Shift+Command+2) or with ideviceinstaller:

$ idevicesyslog -u < udid >

You can use run-loop to tail the log of a simulator.

# Simulator must be launched.  App does not have to be running.
$ run-loop simctl tail
jmoody
  • 2,480
  • 1
  • 16
  • 22