Closed sureshjoshi closed 4 months ago
Hey, your expectation about find(button: "New XYZ")
is correct, most likely the text you're looking for is different (do you have localization?)
There is a way to quickly find out the text used as the label for your buttons: after you locate them with findAll
, call .labelView().text().string()
on each
Thanks for the quick reply! I was looking into it, and I think I assumed find(button
would be a full-depth search for a Text
, rather than top-level.
The buttons I'm using are very slightly customized Labels, but that's enough to cause a problem with the API.
What I'm using instead is a utility which emulates the functionality I need.
Thanks!
If you don't mind, could you share a snippet of the button and the custom label? find(button
is supposed to do a deep search of text (you can check the implementation of the function), so I'd want to make sure there is no issue in the lib
} label: {
ZStack {
self.label()
.opacity(phase == .idle ? 1 : 0)
}.overlay {
where, label
is a Text
I've got a deeply nested button (too far down to manually get to it), that I'm trying to access as follows:
However, this fails to match. However, if I do a
findAll(ViewType.Button.self)
, I correctly get the two buttons on the page.This is the testing API I'm using now, but in order to make my test less brittle to which button comes first in the list, I'd like to access the label, but I can't seem to grab a labelView off of the button...
Does this
find(button:
API specifically expect a top-levelText
inside?