0

I am having trouble finding a way to uniquely identify a series of buttons (custom checkboxes) that exist within a Cell. The Cell contains data in a series of key value pairs with the checkbox button tied to each key value pair. The problem is that the Cell contains the values for ALL the key value pairs, so I seem to be unable to find just one of the buttons, since they are all identical.

As the UITest code is parsing the data that is supposed to be displaying in the application, I am checking for a custom type associated with the key value pair. If it's a .CheckboxInput, then it performs the below code:

else if case KeyValueType.CheckboxInput = currentType {
    let currentCheckboxInput = currentKeyQuery.buttons["step unchecked"]
    currentCheckboxInput.tap()
    XCTAssert(currentKeyQuery.buttons["step checked"].exists)
}

For reference, currentKeyQuery gets to the Cell and queries for text matching the Key of the key value pair. I'm unable to tap the checkbox button because it's finding all of them that exist in the cell, not just the one associated with the current key value pair it's testing against. Is there any way to associate the button with only the current key value pair since all the checkboxes exist within the same cell?

cchapman
  • 3,269
  • 10
  • 50
  • 68
droff75
  • 1
  • 3
  • I cant understand: You have key-value pairs. Its like "SomeFlag-true"? E.g. you can set key as accessibilityIdentifier (if it is unique) and value as accessibilityValue. After that you can search by value and tap by identifier. – Che Feb 26 '16 at 06:46
  • @Che The key-value pairs are just a way to display data associated with each other in a single cell. The code that provides the data for the cell looks like this: `KeyValueGroup(keyValues: [KeyValue(key: "key1", value: "value1", type: .CheckboxInput(checkboxTitle: "Title1")` There are basically a series of key-value pairs in one key-value group that gets displayed in a single cell. If it's a `.CheckboxInput` type, then it displays the checkbox button and displays the associated "title". Since these all exist in the same cell I can't seem to distinguish between them. – droff75 Feb 26 '16 at 15:57

1 Answers1

0

I was actually able to figure this out, although I can't really explain why it's working. I changed currentCheckboxInput to currentKeyQuery.childrenMatchingType(.Button).matchingIdentifier("step unchecked").elementBoundByIndex(0)

droff75
  • 1
  • 3