Ionic & UITest?


#1

Hey,

is anyone here using Apple’s UITest to test an Ionic app?

I am looking for ways to improve the accessibility labels of my app to remove some “flakiness” (sometimes it works, sometimes it doesn’t) in my tests.

The tests are, of course, already using forceTapElement instead of tap to work at all, but there are still some failures I don’t really understand.

Any experience?


extension XCUIElement {
    func forceTapElement() {
        if self.isHittable {
            self.tap()
        }
        else {
            let coordinate: XCUICoordinate = self.coordinate(withNormalizedOffset: CGVector(dx:0.0, dy:0.0))
            coordinate.tap()
        }
    }
}

#2

The solution here was to use forceTapElement with each button or link that gives an error message until it worked. Not very elegant, but now it seems to work >90% of the time.


#3

Hi @Sujan12,
I am in trouble using Xcode UITest for an ionic app, too, at the moment (see my other post)

As this part is also missing in this nice documentation :wink: --> I guess it is not that easy at all…

What do I do with your code example above, simply paste into my XCTestCase class and use instead of .tap()?

How do you set the accessibility labels in the ionic sources, could you please provide an example for me? My problem is, that my button text might change, so I cannot rely on what becomes the ‘label’, I would like to use another attribute instead, but don’t know how as name and id attributes are ignored…

Am trying to find source code in use of identifying those ionic DOM elements inside of Xcode, but no clue.

I am using ionic, fastlane and fastlane-plugin-ionic as well as fastlane-plugin-ionic_integration, by the way.

Thank you, Anne


#4

Searching the menu button via index is not possible - because buttons may be not rendered out if content or privileges are missing…

Also found this, but inspecting the app and its menu buttons doesn’t take me further, though interesting … https://www.shinobicontrols.com/blog/ios9-day-by-day-day2-ui-testing


#5

Sorry, I won’t be of any help here as I am totally out of this topic the last few months. Giving ids helped if I remember correctly. Good luck!


#6

The attribute aria-label <button aria-label="myLabel" /> is actually usable. Ids didn’t work for me.