Uiautomation - Clicking a custom view does not work

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

I have a scrollview that contains a custom view.

  • The custom view overwrites drawRect and has a TapRecognizer.
  • A custom view is created in the code, and I set its properties
myView.userInteractionEnabled = YES; [myView setIsAccessibilityElement:YES]; [myView setAccessibilityLabel:@"myView"]; 
  • Custom view is added to the scroll list using
 [myScrollView addSubview:myView];
[myScrollView addSubview:myView]; 

Everything works both on the device and on the simulator: it clicks on the view, the callback recognizer is called back and the user view can draw something at the transition point.

I would automate the validation of the view, and then I needed to simulate custom branches 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 click at position x = 56 and y = 576.

Nothing happens, it looks like myView is not getting any click (just in case, I play the sound in TapRecognizer, but it never sounded).

I also tried:

 myView.tap();
myView.tap(); 

no success.

Any idea?

Thanks in advance.

Fab.

+4
source share
2 answers

It may come in handy for you. I wrote a test that selects specific x / y coordinates. Instead of touching the scroll, try clicking the window as shown below.

For this, 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.

+1
source

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

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

0
source

Source: https://habr.com/ru/post/1345085/


All Articles