google/EarlGrey

How to find a element that is sibling to a label named "xx"

countryLane opened this issue · 1 comments

There is tableview, that shows a list of products. Each cell has an adding button and a product name. How can I find a cell named "xx" and click the adding button in the cell?

I use this to get the cell with a specific name

static func onCell(text: String, file: StaticString = #file, line: UInt = #line) -> GREYInteraction {
    return selectElement(
      with: grey_allOf(
        NSArray(
          array: [
            grey_kindOfClass(UITableViewCell.self),
            grey_descendant(grey_containsText(text)),
            grey_interactable()
          ]
        ) as! [GREYMatcher]
      )
    ).atIndex(0)
  }