xcode: Timestamped Event Matching Error: Failed to find matching element

浪尽此生 提交于 2019-12-14 00:15:31

问题


I'm trying to record some XCUITesting functions. I get this error.

Timestamped Event Matching Error: Failed to find matching element

Is this an Xcode bug and/or issues with the complexity of my UI?


回答1:


I was having the same problem for a long time on a very complex app as well: The key is all in isAccessibilityElement being set to YES. UI testing and accessibility go hand-in-hand. The way I think about it is that the device needs to be able to interact with the element, since ostensibly, the user wouldn't be able to.

I did this twice:

  1. In cellForRowAtIndexPath - cell.isAccessibilityElement = YES

  2. In awakeFromNib in a UITableViewCell subclass - self.isAccessibilityElement = YES

Hope that helps, and good luck!




回答2:


Try manipulating with items isAccessibilityElement property. As far as I know containers like tableView should have this property set to NO in order to items contained inside them be accessible

Quote from https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAccessibility_Protocol/#//apple_ref/occ/instp/NSObject/isAccessibilityElement :

Assistive applications can get information only about objects that are represented by accessibility elements. Therefore, if you implement a custom control or view that should be accessible to users with disabilities, set this property to YES. The only exception to this practice is a view that merely serves as a container for other items that should be accessible.




回答3:


You need to add key path value to your UI elements as below. For an example, if you are using a tableview then select it in the Storyboard and then click on Identity Inspector. Now enter the following value isAccessibilityElement in the key and tick the checkbox as shown in the image below.

Also if you can't tap on the UITableViewCell or the subclasses, then enable the Accessibility option as shown below.

hereafter it should work just fine.



来源:https://stackoverflow.com/questions/36597862/xcode-timestamped-event-matching-error-failed-to-find-matching-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!