lib/appium_lib/android/helper.rb in appium_lib-0.5.1 vs lib/appium_lib/android/helper.rb in appium_lib-0.5.2

- old
+ new

@@ -14,26 +14,172 @@ # because android can't tell what a secure textfield is # they're all edittexts. # must match names in AndroidElementClassMap (Appium's Java server) case tag_name + when 'abslist' + prefix 'AbsListView' + when 'absseek' + prefix 'AbsSeekBar' + when 'absspinner' + prefix 'AbsSpinner' + when 'absolute' + prefix 'AbsoluteLayout' + when 'adapterviewanimator' + prefix 'AdapterViewAnimator' + when 'adapterviewflipper' + prefix 'AdapterViewFlipper' + when 'analogclock' + prefix 'AnalogClock' + when 'appwidgethost' + prefix 'AppWidgetHostView' + when 'autocomplete' + prefix 'AutoCompleteTextView' when 'button' prefix 'Button', 'ImageButton' - when 'text' - prefix 'TextView' - when 'list' - prefix 'ListView' - when 'window', 'frame' + when 'breadcrumbs' + prefix 'FragmentBreadCrumbs' + when 'calendar' + prefix 'CalendarView' + when 'checkbox' + prefix 'CheckBox' + when 'checked' + prefix 'CheckedTextView' + when 'chronometer' + prefix 'Chronometer' + when 'compound' + prefix 'CompoundButton' + when 'datepicker' + prefix 'DatePicker' + when 'dialerfilter' + prefix 'DialerFilter' + when 'digitalclock' + prefix 'DigitalClock' + when 'drawer' + prefix 'SlidingDrawer' + when 'expandable' + prefix 'ExpandableListView' + when 'extract' + prefix 'ExtractEditText' + when 'fragmenttabhost' + prefix 'FragmentTabHost' + when 'frame' prefix 'FrameLayout' + when 'gallery' + prefix 'Gallery' + when 'gesture' + prefix 'GestureOverlayView' + when 'glsurface' + prefix 'GLSurfaceView' when 'grid' prefix 'GridView' - when 'relative' - prefix 'RelativeLayout' + when 'gridlayout' + prefix 'GridLayout' + when 'horizontal' + prefix 'HorizontalScrollView' + when 'image' + prefix 'ImageView' + when 'imagebutton' + prefix 'ImageButton' + when 'imageswitcher' + prefix 'ImageSwitcher' + when 'keyboard' + prefix 'KeyboardView' when 'linear' prefix 'LinearLayout' + when 'list' + prefix 'ListView' + when 'media' + prefix 'MediaController' + when 'mediaroutebutton' + prefix 'MediaRouteButton' + when 'multiautocomplete' + prefix 'MultiAutoCompleteTextView' + when 'numberpicker' + prefix 'NumberPicker' + when 'pagetabstrip' + prefix 'PageTabStrip' + when 'pagetitlestrip' + prefix 'PageTitleStrip' + when 'progress' + prefix 'ProgressBar' + when 'quickcontactbadge' + prefix 'QuickContactBadge' + when 'radio' + prefix 'RadioButton' + when 'radiogroup' + prefix 'RadioGroup' + when 'rating' + prefix 'RatingBar' + when 'relative' + prefix 'RelativeLayout' + when 'row' + prefix 'TableRow' + when 'rssurface' + prefix 'RSSurfaceView' + when 'rstexture' + prefix 'RSTextureView' + when 'scroll' + prefix 'ScrollView' + when 'search' + prefix 'SearchView' + when 'seek' + prefix 'SeekBar' + when 'space' + prefix 'Space' + when 'spinner' + prefix 'Spinner' + when 'stack' + prefix 'StackView' + when 'surface' + prefix 'SurfaceView' + when 'switch' + prefix 'Switch' + when 'tabhost' + prefix 'TabHost' + when 'tabwidget' + prefix 'TabWidget' + when 'table' + prefix 'TableLayout' + when 'text' + prefix 'TextView' + when 'textclock' + prefix 'TextClock' + when 'textswitcher' + prefix 'TextSwitcher' + when 'texture' + prefix 'TextureView' when 'textfield' prefix 'EditText' + when 'timepicker' + prefix 'TimePicker' + when 'toggle' + prefix 'ToggleButton' + when 'twolinelistitem' + prefix 'TwoLineListItem' + when 'video' + prefix 'VideoView' + when 'viewanimator' + prefix 'ViewAnimator' + when 'viewflipper' + prefix 'ViewFlipper' + when 'viewgroup' + prefix 'ViewGroup' + when 'viewpager' + prefix 'ViewPager' + when 'viewstub' + prefix 'ViewStub' + when 'viewswitcher' + prefix 'ViewSwitcher' + when 'web' + prefix 'WebView' + when 'window' + prefix 'FrameLayout' + when 'zoom' + prefix 'ZoomButton' + when 'zoomcontrols' + prefix 'ZoomControls' else raise "Invalid tag name #{tag_name}" end # return result of case end # Find all elements matching the attribute @@ -127,13 +273,11 @@ # out += " visible: #{e[:shown]}\n" unless e[:shown].nil? } out end - # Count all classes on screen and print to stdout. - # Useful for appium_console. - def page_class + def get_page_class r = [] run_internal = lambda do |node| if node.kind_of? Array node.each { |node| run_internal.call node } return @@ -146,14 +290,21 @@ run_internal.call node['node'] if keys.include?('node') end json = get_source run_internal.call json['hierarchy'] + res = '' r = r.sort r.uniq.each do |ele| - print r.count(ele) - puts "x #{ele}\n" + res += "#{r.count(ele)}x #{ele}\n" end + res + end + + # Count all classes on screen and print to stdout. + # Useful for appium_console. + def page_class + puts get_page_class nil end # Android only. # Returns a string containing interesting elements. \ No newline at end of file