I would like to be able to tap a concrete button on my stack of views. To achieve this, first I set on my code an accessibility id:
Button(action: {
withAnimation(.easeOut(duration: 1)) {
self.modalShown.toggle()
}
}) {
FilterButton()
.accessibility(identifier: "modalFilterViewBtn")
}
.buttonStyle(PlainButtonStyle())
}
So, then on my text case I tried to look for that id:
IOSElement elem1 = driver.findElementByAccessibilityId("modalFilterViewBtn");
wait.until(ExpectedConditions.elementToBeClickable(elem1));
elem1.click();
And I obtain as a result: An element could not be located on the page using the given search parameters.(..)
Finally if I use the Appium inspector to know the accessibility id of my desired element, it seems to be another name that is not the same that I had set in code:
Even if I look for the element with that id("Filter"), it also can not be found during my test case.
So, what is the correct way to set this accessibility id using SwiftUI?
Thank you
I assume it should be like
Button(action: {
// action here
}) {
// button label view here
}
.buttonStyle(PlainButtonStyle())
.accessibility(identifier: "modalFilterViewBtn")
Note in iOS 14+ there is .accessibilityIdentifier(_ identifier: String)
instead. accessibility(identifier: String)
is deprecated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With