问题描述
有一个包含收藏夹视图"的单元格.我已经使用
There is a cell contains a Collection View. I have set the cells within a Collection View using
cell.accessibilityLabel = @"daren_shangjia_0001_add_new_photo_album";
然后在XCTest中,我做
and then in XCTest, I do
print(app.debugDescription);
我没有看到提供的accessibilityLabel.
I didn't see the accessibilityLabel that I have provided.
Element subtree:
→Application 0x608000367200: {{0.0, 0.0}, {414.0, 736.0}}, label: '纳豆行'
Window 0x608000365e80: Main Window, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x608000365880: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x608000365b80: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x608000365700: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x608000364d40: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x608000364680: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x608000364740: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x608000364800: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
NavigationBar 0x6080003648c0: traits: 35192962023424, {{0.0, 20.0}, {414.0, 44.0}}, identifier: '140'
Button 0x608000364980: traits: 8589934593, {{20.0, 31.0}, {20.7, 20.5}}, label: 'da ren list backBtn'
StaticText 0x608000365f40: traits: 8590000192, {{192.0, 28.0}, {30.0, 27.0}}, label: '140'
Button 0x608000366000: traits: 8589934593, {{360.7, 25.0}, {33.3, 33.1}}, label: 'denglu 0010 you ke register'
Other 0x608000366240: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x6000003660c0: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Other 0x600000365e80: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
Table 0x600000365dc0: traits: 35192962023424, {{0.0, 0.0}, {414.0, 680.8}}
Image 0x608000366a80: traits: 8589934596, {{0.0, 64.0}, {414.0, 219.6}}
Image 0x608000366cc0: traits: 8589934596, {{168.4, 135.2}, {77.3, 77.3}}
Button 0x608000367080: traits: 8589934593, {{151.8, 118.6}, {110.4, 110.4}}
Image 0x6080003672c0: traits: 8589934596, {{245.2, 195.3}, {16.6, 16.6}}, identifier: 'da_ren_list_girl'
推荐答案
要访问容器视图中的视图,必须确保无法访问该容器视图.就您而言,我认为这是表格视图单元格.
To access a view within a container view, you must ensure that the container view is not accessible. In your case, I think this is the table view cell.
let cell: UITableViewCell!
cell.isAccessibilityElement = false
为降低辅助功能用户的复杂性,在屏幕的任何部分上最多可以有一个辅助视图.单元格通常是包含信息的事物,这些信息可以概括为单个实体,例如,表示一个包含文本和图片的项目,并带有选择它的选项.由于您已经决定拥有一个非常复杂的单元格,因此您需要更改其默认行为,以允许辅助功能用户更细致地访问单元格的内容.不能再在表视图单元格级别上对其进行汇总.因此,解释屏幕上的内容的工作必须传递给视图层次结构中较低的元素.
To reduce complexity for Accessibility users, there will be a maximum of one accessible view on any part of the screen. A cell is usually something which contains information which can be summarised as a single entity, for example, representing an item which includes text and a picture with the option to select it. Since you have decided to have quite a complex cell, you need to change the default behaviour of it to allow Accessibility users more granular access to the contents of the cell. It can no longer be summarised at the table view cell level. So the job of explaining what is on the screen must be passed to elements lower in the view hierarchy.
要进一步了解该概念,请尝试在打开VoiceOver的情况下使用您的应用,并使用三指三指轻按以切换屏幕帷幕.
To further understand this concept, try using your app with VoiceOver turned on and use a triple three-finger tap to toggle the screen curtain.
这篇关于XCTest UI测试:在表格单元格内找不到collectionView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!