I'm trying to get the value of every class using query command. Below is the sample UI component that I get:
[0] {
"class" => "UITabBarSwappableImageView",
"id" => "imageView-34",
"rect" => {
"center_x" => 288,
"y" => 522,
"width" => 48,
"x" => 264,
"center_y" => 538,
"height" => 32
},
"frame" => {
"y" => 2,
"width" => 48,
"x" => 6,
"height" => 32
},
"label" => nil,
"description" => "<UITabBarSwappableImageVie....>"
On Android, I can just use this to list all the values of class components:
query("*", :class)
However, I can't seem to use the same command on iOS. I get this as the result:
irb(main):135:0> query "*", :class
[
[ 0] nil,
[ 1] nil,
[ 2] nil,
[ 3] nil
]
I know that with the labels, I can use :accessibilityLabel to do the job, but not when I try to get value from class/id/etc.
Could someone please shed some light?
Short answer: 'class' is not a selector on UIView instances
Long answer:
Taking a step back, I think I know what you are trying to do - get a comprehensive list of views that are visible.
Have a look at https://github.com/jmoody/briar/blob/master/lib/briar/irbrc.rb
Example output is here: https://gist.github.com/jmoody/8031917
Instead of calling 'class' in the query, iterate over the results returned by query and look for the value of the 'class' key.