iphone - uiautomation - 点击自定义 View 不起作用

标签 iphone ipad testing ios-ui-automation

我正在尝试对我的 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/

相关文章:

ruby-on-rails - 如何编写范围和存在 : true RSpec Rails 的 validates_uniqueness_of 测试

testing - Windows Phone 8 有类似 Testflight 的东西吗?

iphone - 使用 OpenGL ES 在运行时向图像添加鱼眼效果

ios - 使用 AVAssetWriter 录制视频

iphone - UI窗口动画

ios - 我们可以为一个 View Controller 使用两个不同的 Xib 吗?

arrays - selenium ide循环遍历数组变量

iphone - 使用加速度计或陀螺仪计数步骤

iphone - 允许 iPhone 应用程序与 iTunes 同步

ios - 解释从 iOS 中的蓝牙体重秤设备接收到的字节