我正在使用XCUIApplication编写UI测试.我正在测试单元格行上的选定索引.当我运行测试时,我无法获得所选索引的文本.但是,我可以单击所选行,但使用底部tableView的静态文本.当下面有tableViewController时会发生这种情况.我试图在另一个TableViewController的顶部添加一个带有tableView的ViewController.下面的tableViewController是使用storyboard生成的,但上面的viewController是动态生成的.
设置:我正在使用xib作为tableView的行,我正在使用带有标签和图像的自定义UITableViewCell.标签和图像都打开了辅助功能,但没有打开细胞.我试过在单元格上打开辅助功能但仍然无法正常工作.
这是我的考验
//the BoxListTable is my ViewController that is on top
// I added the following code in that viewController:
self.view.isAccessibilityElement = true
self.view.accessibilityIdentifier = "BoxListTable"
//I also added these for the tableView but it doesn't show up in my tests
tableView.accessibilityIdentifier = "tableview"
tableView.isAccessibilityElement = true
//my test is the following
XCUIApplication().tables["BoxListTable"].tap()
Run Code Online (Sandbox Code Playgroud)
当我运行此测试时,测试单击完整的tableView但无法获取任何静态文本.它也无法获取任何单元格或tableview.po XCUIApplication.tables ["BoxListTable"].cells.count返回0. //我试过
XCUIApplication.tables ["BoxListTable"].element.children(匹配:.other)
返回0
你能否告诉我为什么即使设置了accessibilityIdentifier也无法看到它.