简体   繁体   English

无法让 UI 测试选择静态表格视图单元格

[英]Can't get UI Testing to select a static table view cell

I'm trying to use UI Tests to take screenshots of my app.我正在尝试使用 UI 测试来截取我的应用程序的屏幕截图。

The app is localized, so I can't have the automation look for the text, because it changes according to the current language.该应用程序已本地化,因此我无法自动查找文本,因为它会根据当前语言进行更改。

I have a lot of static table views with cells that segue to other view controllers, and I managed to get Xcode to select them by adding accessibility identifiers to their labels and using the identifiers instead of the text.我有很多带有单元格的静态表视图,这些单元格与其他视图控制器相连,我设法通过向标签添加可访问性标识符并使​​用标识符而不是文本来让 Xcode 选择它们。

For other cells, though, that doesn't work, I don't know why.但是,对于其他单元格,这不起作用,我不知道为什么。 Even if the identifiers are set just like for the other cells, Xcode keeps telling me there were no matches found.即使像其他单元格一样设置标识符,Xcode 也会不断告诉我没有找到匹配项。 Also if I try to record my interaction, for the cells that work Xcode will record the identifier I have set, but for the ones that don't it will just use the label's text.此外,如果我尝试记录我的交互,对于工作 Xcode 的单元格将记录我设置的标识符,但对于那些不记录的单元格,它将只使用标签的文本。 It's like I didn't even set an identifier for those labels, even though I did.就好像我什至没有为这些标签设置标识符,即使我做了。

Does anyone have a clue about what's happening here?有没有人知道这里发生了什么? And are there any better alternatives to select a cell?有没有更好的选择来选择单元格?

Thanks in advance,提前致谢,

Daniel丹尼尔

Well, I still don't know why the accessibility identifiers aren't working for those cells, but I managed to select them using this:好吧,我仍然不知道为什么可访问性标识符不适用于这些单元格,但我设法使用以下方法选择它们:

    let cells = app.tables.cells
    cells.elementBoundByIndex(3).tap()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM