MKAnnotation通过XCTest UI测试

Chr*_*son 1 mkannotation xctest xcode-ui-testing swift3 xcode8

如何通过XCTest的UI测试访问MKMapView上的引脚?

我想计算数字,验证具体的数字(基于可访问性ID或标题)等.

MKAnnotation似乎没有XCUIElementType.

我很难找到关于MKMapView + XCTest的任何文档.

Mac*_*iło 6

maps不幸的是,注释视图不在其中.你会在那里找到感兴趣的地图点.要查询您应该使用的注释视图XCUIApplication().windows.element.otherElements["Custom Identifier"].

添加accessibilityIdentifier = "Custom Identifier"到注释视图,而不是注释.MKAnnotation没有实现accessibilityIdentifier.

  • 你可以只使用`app.otherElements["Custom Identifier"]` (2认同)