I'm trying to write some UI tests for my app and i'm using a third party popup view library. Under the hood i see it's using the fullscreenCover view modifier.
My tested class looks something like this
struct FirstTimeView: View { var body: some View { TabView(selection: $selection) { <some views for tab view> // one of the above views contains a tap taht toggles showLegendView } .tabViewStyle(PageTabViewStyle()) .popup(isPresented: self.$showLegendView, view: { LegendView() .cornerRadius(15) .accessibilityIdentifier("legend") }, customize: popupDefaultCustomisationWithOpaqueAndCloseOnTap) } and my test class looks something like this
app.staticTexts[<id of element to toggle showLegendView>].firstMatch.tap() If I tap on the popup view wherever, it's dismissed, but i want to tap on an element inside it so i can also test that it exists there
app.staticTexts["legend"].firstMatch.tap() if I put a breakpoint on the above line and print the static texts of the app I get
Find: Target Application 'com.test' Output: { Application, 0x1023212c0, pid: 40158, label: 'test' } ↪︎Find: Descendants matching type StaticText Output: { StaticText, 0x102716de0, {{349.0, 638.7}, {18.0, 14.0}}, identifier: 'legend', label: 'test1' StaticText, 0x102717500, {{277.2, 638.7}, {46.7, 14.0}}, identifier: 'legend', label: 'test2' StaticText, 0x102717bd0, {{233.2, 638.7}, {19.7, 14.0}}, identifier: 'legend', label: 'test3' But if i let the code run I get
t = 397.10s Tap "legend" StaticText t = 397.11s Wait for com.test to idle t = 397.12s Find the "legend" StaticText t = 397.14s Check for interrupting elements affecting "legend" StaticText t = 397.21s Synthesize event t = 397.24s Scroll element to visible t = 397.24s Find the "legend" StaticText t = 397.28s Computed hit point {-1, -1} after scrolling to visible t = 397.28s Failed: Failed to scroll to visible (by AX action) StaticText, {{349.0, 638.7}, {18.0, 14.0}}, identifier: 'legend', label: 'test1', error: Error kAXErrorCannotComplete performing AXAction kAXScrollToVisibleAction on element AX element pid: 40158, elementOrHash.elementID: 105553169980768.46 Not sure why this is happening.
Any ideas? 🙏
