MGSwipeTableCell: Accessing Buttons in UITests does not work

Hi!

I’m currently trying to build some tests using the new UITest feature in Xcode 7. Unfortunately I’m not able to figure out how to access the MGSwipeButton from it. What’s wrong?

In cellForRowAtIndexPath:

let deleteButton = MGSwipeButton(title:NSLocalizedString("Delete",comment:"Delete"), backgroundColor:AppAppearance.deleteColor)
deleteButton.accessibilityLabel = NSLocalizedString("Delete",comment:"Delete")

cell?.rightButtons = [ deleteButton ]

And afterwards, if I try to record the test Xcode generates the following code:

let marcoBetschartStaticText = XCUIApplication().tables.staticTexts["Marco Betschart"]
marcoBetschartStaticText.swipeLeft()
marcoBetschartStaticText.tap()

Which - of course - just closes the swipeable button area when run.

So how to access the MGSwipeButton’s in UITests?

About this issue

  • Original URL
  • State: open
  • Created 9 years ago
  • Comments: 26 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Finally I had some time to work on this issue. The problem seems that the default UITableViewCell implementation doesn’t really use/return all cell.contentView subviews in the accessibility protocol implementation. I have overridden UIAccessibilityContainer protocol to use contentView when the cell is swipped and fallback to default implementation when a cell is not in a swipped state.

I have tested with the Accessibility Inspector and a new XCTest project and both seems to work well now.

Let me know if it works in your projects now 😉

The commit is the master branch by now, I want to work on other issue before pushing 1.5.6 to CocoaPods

Interesting, I will have to put together a test with XCTest, was assuming apple used the same libraries underneath for UIAutomation and xcuitest and my assumption was wrong. I will debug into this later this week and see if I can come up with anything. I will be moving to over next month so I am assuming I will be running into this issue and will be needing it fixed when I get there.

edit: I was unable to figure out why xcuitest behaves the way it does with this library. Will be a while before I can try another deep dive so if anyone else wants to try to debug it, go ahead.

Please, @MortimerGoro, help us with this issue.