【发布时间】:2018-06-28 15:32:13
【问题描述】:
实际场景是这样的,我有多个section的tableView,并且使用了reusableTableHeaderFooterView。可重用视图内部有多个元素。 IE。标签、按钮等
在将 headerView 出列并按照以下代码在配置方法中设置可访问性之后,我正在 viewForHeaderInSection 中调用配置方法。
在 ViewController 中
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let customHeader:CustomHeader = tableView.dequeueReusableHeaderFooterView(withIdentifier: "CustomHeader") as! CustomHeader
customHeader.configureWith(section: section)
return customHeader
}
CustomHeaderView
class CustomHeader: UITableViewHeaderFooterView {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var seeAllButton: UIButton!
override func awakeFromNib() {
super.awakeFromNib()
}
func configureWith(section:Int){
titleLabel.text = "Section \(section)"
self.isAccessibilityElement = false
titleLabel.isAccessibilityElement = true
seeAllButton.isAccessibilityElement = true
self.accessibilityElements = [titleLabel, seeAllButton]
titleLabel.accessibilityIdentifier = "Section Header- \(section)"
seeAllButton.accessibilityIdentifier = "Section Button- \(section)"
}
}
最后,我无法访问某些标题视图的元素。它适用于屏幕加载时已经显示在屏幕上的标题视图,但不适用于滚动后显示的部分。
在 appium 桌面应用程序中,我无法选择 headerView 中的元素,如下所示。即使我通过accessibilityId搜索元素后也找不到它。
** 预期:** 在第 3 节中正常工作
** 意外 ** 不适用于第 4 节
【问题讨论】:
-
我也面临同样的问题。你找到解决办法了吗?
-
是的,但不是使用相同的代码,我已将实现更改为静态标题而不是可重用的标题视图,它对我有用。 @prasad
标签: ios swift uitableview automation appium