UITest label color (not UI label)

Here is an example of the table I'm working with.

enter image description here

I'm just trying to get the color “requested” (gray) or “draft” (orange). I can get the actual string “requested” or “draft” on

var timeSheetStatus = app.tables.element.cells.elementBoundByIndex(0).staticTexts.elementBoundByIndex(1).label 

but this is just a string, not UIlabel (if it were UILabel, I could make label.textColor, I think). How to get the color of this line so that I can say that it is really gray or orange?

+6
source share
2 answers

I am afraid that you will not be able to do this through user interface testing. User interface testing can only “see” an interface to the extent that Availability provides it. That way you can “see” the text, but you cannot “see” that this thing is UILabel; User interface testing knows nothing about this. Therefore, you cannot explore its nature as UILabel.

+5
source

You cannot get the color directly, but if you need to test your user interface to make sure your labels are highlighted correctly, you can set an accessibility label to include information such as the color or the fact that it is highlighted.

It will also improve the usability of the application, as users with impaired vision will not see the color in any case. You can then write tests to make sure at least the availability label is correct. Of course, there is a chance that the developer will make the label brighter than green and the accessibility label "yellow", but this is a common risk of using accessibility for request user interface elements.

For example, in your application code:

myLabel.text = "Draft" myLabel.color = .yellow myLabel.accessibilityLabel = "Draft (Yellow)"

0
source

All Articles