I'm currently in the process of writing UI tests for an app that makes liberal use of TagListView; it is a fantastic library! As part of these tests, I need to remove a tag. Clicking the remove button on a tag has proven difficult.
I tried querying for the remove button via XCUIApplication().buttons["tagText"].children(matching: .button).firstMatch but that does not return anything.
I tried adding an accessibility label to the remove button, but because it's internal the only way I could do this was by subclassing TagView, which seems like overkill since it would require more work to make sure my TagListViews always add the subclass with the accessible remove button.
let REMOVE_BTN_OFFSET = CGVector(dx: 0.7, dy: 0.5)
let removeButtonCoord = app.buttons["B"].coordinate(
withNormalizedOffset: REMOVE_BTN_OFFSET)
removeButtonCoord.tap()
This only works because I know exactly what the content in the tag I'm trying to remove is. I'm wondering if the maintainers would be open to making clicking this a bit easier? Some possible solutions:
Always attach an a11y id of remove:<tagText> to the remove button
Remove the internal access modified from removeButton and make it private(set) or similar. I feel like UIKit exposes similar subviews within its views (e.g. titleLabel for UIButton).
Happy to contribute as well. Thanks again for building such a great library!
I'm currently in the process of writing UI tests for an app that makes liberal use of
TagListView
; it is a fantastic library! As part of these tests, I need to remove a tag. Clicking the remove button on a tag has proven difficult.I tried querying for the remove button via
XCUIApplication().buttons["tagText"].children(matching: .button).firstMatch
but that does not return anything.I tried adding an accessibility label to the remove button, but because it's internal the only way I could do this was by subclassing
TagView
, which seems like overkill since it would require more work to make sure myTagListView
s always add the subclass with the accessible remove button.What I would up doing was tapping on a specific portion of the tag view that I knew contained the remove button:
This only works because I know exactly what the content in the tag I'm trying to remove is. I'm wondering if the maintainers would be open to making clicking this a bit easier? Some possible solutions:
remove:<tagText>
to the remove buttoninternal
access modified from removeButton and make itprivate(set)
or similar. I feel like UIKit exposes similar subviews within its views (e.g.titleLabel
forUIButton
).Happy to contribute as well. Thanks again for building such a great library!