我正在尝试对我的 ipad 应用程序进行一些自动化测试。
我有一个包含自定义 View 的 ScrollView 。
- 自定义 View 覆盖 drawRect 并具有 TapRecognizer。
- 自定义 View 已创建到代码中,我已设置此属性
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});
模拟用户在位置 x=56 和 y=576 处点击。
没有任何反应,似乎 myView 没有收到任何点击(以防万一,我向 TapRecognizer 播放了一个声音,但它从未被播放过)。
我也试过:
myView.tap();
没有成功。
有什么想法吗?
提前谢谢你。
很棒。
最佳答案
这可能对你有用。我写了一个测试来点击特定的 x/y 坐标。不要触摸 ScrollView ,而是尝试点击窗口,如下所示。
为此我写道:
var window = UIATarget.localTarget();
window.tap({x:x_co , y:y_co});
x_co 和 y_co 是我的坐标。
希望这对您有所帮助。
关于iphone - uiautomation - 点击自定义 View 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5419856/