4

I am trying to automate some tests of my ipad application.

I have a scrollview which contains a custom view.

  • The custom view overwrites the drawRect and has a TapRecognizer.
  • The custom view is created into the code and I have set this properties

myView.userInteractionEnabled = YES;
[myView setIsAccessibilityElement:YES];
[myView setAccessibilityLabel:@"myView"];

  • The custom view is added to the scrollview with

[myScrollView addSubview:myView];

Everything works smooth both on device and on simulator: tapping on the view, the tap recognizer callback is called and the custom view can draw something at the tap point.

I would automate the view test and then I need to simulate user's taps on myView.

In the uiautomation script I have something like this:

myView = circuitScrollView.elements()[0];       
myView.logElement();
myView.tapWithOptions({x:56, y:576});

to simulate a user tap at position x=56 and y=576.

Nothing happens, it seems that myView doesn't receive any tap (just in case, I play a sound into the TapRecognizer but it has never been sounded).

I have tryed this too:


myView.tap();

no success.

Any idea ?

Thank you in advance.

Fab.

nschum
  • 15,322
  • 5
  • 58
  • 56
Fab
  • 1,468
  • 1
  • 16
  • 37
  • Try circuitScrollView.logElementTree() to determine which elements are accesable at all. I would guess your custum view is not in that list. This is not the solution to your problem but might be a step to solve it. – Rene Berlin Mar 25 '11 at 11:01
  • I read somewhere that having containers with accessibility turned on interferes with it's child elements. – Martin Wickman Jun 28 '11 at 09:26
  • Fabrizio, how were you able to access your UIScrollView? – Rui Peres Jul 19 '11 at 18:07

2 Answers2

1

This may be of some use to you. I wrote a test that taps certain x/y coordinates. Rather than touching the scroll view try tapping the window as demonstrated below.

To do so I wrote:

   var window = UIATarget.localTarget(); 
   window.tap({x:x_co , y:y_co}); 

x_co and y_co were my coordinates.

Hope this helps.

sjngm
  • 12,423
  • 14
  • 84
  • 114
Dan
  • 1,447
  • 2
  • 14
  • 30
  • 1
    If you take UIATarget.localTarget() you have a UIATarget, not an UIAWindow. And even so the tap method doesn't accept arguments. Did you test this script? – hariseldon78 Jun 25 '12 at 14:19
0

Maybe myView = circuitScrollView.elements()["myView"] might help instead of myView = circuitScrollView.elements()[0]; ?

Maybe your custom view is not the first element in the element tree of your circuitScrollView...

Rene Berlin
  • 1,171
  • 7
  • 21