Ale*_*one 2 objective-c ios ios9 xcode7 xcode-ui-testing
我的应用程序中有以下手势识别器.我查看了xCode7用户界面并看到它向上/向下/向左/向右滑动,但没有平移或边缘平移手势.
如何测试或启动屏幕边缘平移手势以用于UITesting目的?
UIScreenEdgePanGestureRecognizer *leftEdgeGesture = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(show)];
leftEdgeGesture.edges = UIRectEdgeLeft;
leftEdgeGesture.delegate = self;
[self.view addGestureRecognizer:leftEdgeGesture];
Run Code Online (Sandbox Code Playgroud)
Chr*_*her 11
我花了一些时间试图解决这个问题,在元素层次结构中导航.很多很多的谷歌搜索没有找到任何东西.
我放弃了两次,然后想出来了.
我们只需要在主应用程序屏幕上显示两个坐标,然后将其中一个拖动到另一个屏幕上.
干得好吃!
XCUIApplication *app = [[XCUIApplication alloc] init];
[app launch];
// Set a coordinate near the left-edge, we have to use normalized coords
// so you set using percentages, 1% in on the left, 15% down from the top
XCUICoordinate *coord1 = [app coordinateWithNormalizedOffset:CGVectorMake(0.01, 0.15)];
// Then second coordinate 40 points to the right
XCUICoordinate *coord2 = [coord1 coordinateWithOffset:CGVectorMake(40, 0)];
// Perform a drag from coord1 to coord2
// Simulating swipe in from left edge
[coord1 pressForDuration:0.5f thenDragToCoordinate:coord2];
Run Code Online (Sandbox Code Playgroud)
希望这将有助于其他一直在努力模拟边缘滑动的人.
| 归档时间: |
|
| 查看次数: |
1483 次 |
| 最近记录: |