File tree 1 file changed +46
-0
lines changed
1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -198,3 +198,49 @@ def get_source
198
198
def password length = 1
199
199
'•' * length
200
200
end
201
+
202
+ # Android only.
203
+ def get_inspect
204
+ def run node
205
+ r = [ ]
206
+
207
+ run_internal = lambda do |node |
208
+ if node . kind_of? Array
209
+ node . each { |node | run_internal . call node }
210
+ return
211
+ end
212
+
213
+ keys = node . keys
214
+ return if keys . empty?
215
+
216
+ obj = { }
217
+ obj . merge! ( { desc : node [ "@content-desc" ] } ) if keys . include? ( "@content-desc" ) && !node [ "@content-desc" ] . empty?
218
+ obj . merge! ( { text : node [ "@text" ] } ) if keys . include? ( "@text" ) && !node [ "@text" ] . empty?
219
+ obj . merge! ( { class : node [ "@class" ] } ) if keys . include? ( "@class" ) && !obj . empty?
220
+
221
+ r . push obj if !obj . empty?
222
+ run_internal . call node [ 'node' ] if keys . include? ( 'node' )
223
+ end
224
+
225
+ run_internal . call node
226
+ r
227
+ end
228
+
229
+ json = JSON . parse ( $driver. page_source )
230
+ node = json [ 'hierarchy' ]
231
+ results = run node
232
+
233
+ out = ''
234
+ results . each { |e |
235
+ out += e [ :class ] . split ( '.' ) . last + "\n "
236
+ out += " text: #{ e [ :text ] } \n " unless e [ :text ] . nil?
237
+ out += " desc: #{ e [ :desc ] } \n " unless e [ :desc ] . nil?
238
+ }
239
+ out
240
+ end
241
+
242
+ # Android only. Intended for use with console.
243
+ def inspect
244
+ puts get_inspect
245
+ nil
246
+ end
You can’t perform that action at this time.
0 commit comments