【问题标题】:Appium automation is not able to find elementByAccessibilityId of reusableTableHeaderFooterViewAppium自动化无法找到reusableTableHeaderFooterView的elementByAccessibilityId
【发布时间】: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


【解决方案1】:

应用程序是在混合应用程序中制作的吗?我更喜欢使用 xpath 插入辅助功能 ID,开发人员需要为辅助功能 ID 添加属性。

【讨论】:

  • 不,它不是混合应用程序,它是原生 iOS 应用程序。我已经为所有这些元素提供了可访问性 ID。
猜你喜欢
  • 1970-01-01
  • 2017-08-03
  • 2018-05-10
  • 1970-01-01
  • 1970-01-01
  • 2015-07-31
  • 2018-10-21
  • 2020-04-09
  • 1970-01-01
相关资源
最近更新 更多