Still a problem 3 years later on Xcode 13.3.1 13E500a.
A workaround we are using is to wait for other elements to disappear or appear before waiting for the button to be hittable.
Such as
Waiting for a UIActivityIndicator to not exist
Waiting for a navigation bar to exist with certain text
Wait for a collection view to exist with a cell count
Seems to give the XCUIApplication more time to avoid the error
Post
Replies
Boosts
Views
Activity
Xcode 14.1 beta 2 working code sample
https://github.com/mszpro/iOS16.1-LiveActivities-DynamicIsland-Demo
Hey it took me days to figure it out, but the way is to use a custom date formatter. See example code below
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Text(date, formatter: formatter)
}
.padding()
}
var date: Date {
Date().addingTimeInterval(20*60)
}
var formatter: RelativeMinutesDateFormatter {
RelativeMinutesDateFormatter()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
class RelativeMinutesDateFormatter : Formatter {
open override func string(for obj: Any?) -> String? {
guard let date = obj as? Date else {
return nil
}
let minutes = Int(date.timeIntervalSince(.now) / 60)
return "\(minutes)m"
}
}