File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,33 @@ def run node
129
129
out
130
130
end
131
131
132
+ # Count all classes on screen and print to stdout.
133
+ # Useful for appium_console.
134
+ def page_class
135
+ r = [ ]
136
+ run_internal = lambda do |node |
137
+ if node . kind_of? Array
138
+ node . each { |node | run_internal . call node }
139
+ return
140
+ end
141
+
142
+ keys = node . keys
143
+ return if keys . empty?
144
+ r . push node [ '@class' ] if keys . include? ( '@class' )
145
+
146
+ run_internal . call node [ 'node' ] if keys . include? ( 'node' )
147
+ end
148
+ json = get_source
149
+ run_internal . call json [ 'hierarchy' ]
150
+
151
+ r = r . sort
152
+ r . uniq . each do |ele |
153
+ print r . count ( ele )
154
+ puts "x #{ ele } \n "
155
+ end
156
+ nil
157
+ end
158
+
132
159
# Android only.
133
160
# Returns a string containing interesting elements.
134
161
# If an element has no content desc or text, then it's not returned by this method.
You can’t perform that action at this time.
0 commit comments