uiautomation - Tapping custom view doesn't work
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.
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.
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...
精彩评论