From 84c06ecd6dcd19fca732ba2bba213e9c9ef1dfdc Mon Sep 17 00:00:00 2001 From: Kazuaki MATSUO Date: Sat, 6 May 2017 17:15:28 +0900 Subject: [PATCH] revert _fix_android_native_source and instance counting --- lib/appium_lib/android/helper.rb | 46 +++----------------------------- lib/appium_lib/driver.rb | 3 +-- 2 files changed, 5 insertions(+), 44 deletions(-) diff --git a/lib/appium_lib/android/helper.rb b/lib/appium_lib/android/helper.rb index 5e9c42e0..66b51934 100644 --- a/lib/appium_lib/android/helper.rb +++ b/lib/appium_lib/android/helper.rb @@ -3,7 +3,7 @@ module Android # @private # http://nokogiri.org/Nokogiri/XML/SAX.html class AndroidElements < Nokogiri::XML::SAX::Document - attr_reader :result, :keys, :instance, :filter + attr_reader :result, :keys, :filter # convert to string to support symbols def filter=(value) @@ -15,22 +15,17 @@ def filter=(value) def initialize reset @filter = false - @instance = Hash.new(-1) end def reset @result = '' @keys = %w(text resource-id content-desc) - @instance = Hash.new(-1) end # http://nokogiri.org/Nokogiri/XML/SAX/Document.html def start_element(name, attrs = []) return if filter && !name.downcase.include?(filter) - # instance numbers start at 0. - number = instance[name] += 1 - attributes = {} attrs.each do |key, value| @@ -78,39 +73,10 @@ def start_element(name, attrs = []) string += " id: #{id}\n" unless id.nil? string += " strings.xml: #{string_ids}" unless string_ids.nil? - @result += "\n#{name} (#{number})\n#{string}" unless attributes.empty? + @result += "\n#{name}\n#{string}" unless attributes.empty? end end # class AndroidElements - # Fix uiautomator's xml dump. - # https://github.com/appium/appium/issues/2822 - # https://code.google.com/p/android/issues/detail?id=74143 - def _fix_android_native_source(source) - # ]*\$[^>]*)>/).flatten.uniq.each do |problem_tag| - # "android.app.ActionBar$Tab" - before, after = problem_tag.split('$') - before.strip! - after.strip! - - fixed = "#{before}.#{after}" - - # now escape . in before/after because they're used in regex - before.gsub!('.', '\.') - after.gsub!('.', '\.') - - # => - source = source.gsub(/<#{before}\s*\$\s*#{after}/, - "<#{fixed}").gsub(/<\/#{before}\s*\$\s*#{after}>/, "") - end - - source - end - # Prints xml of the current page # @return [void] def source @@ -400,14 +366,10 @@ def complex_finds_exact(class_name, value) find_elements :uiautomator, string_visible_exact(class_name, value) end - # Returns XML string for the current page - # Fixes uiautomator's $ in node names. - # `android.app.ActionBar$Tab` becomes `android.app.ActionBar.Tab` + # Returns XML string for the current page via `page_source` # @return [String] def get_source - src = @driver.page_source - src = _fix_android_native_source src unless src && src.start_with?('') - src + @driver.page_source end end # module Android end # module Appium diff --git a/lib/appium_lib/driver.rb b/lib/appium_lib/driver.rb index 8cf4ee66..7af74ee3 100644 --- a/lib/appium_lib/driver.rb +++ b/lib/appium_lib/driver.rb @@ -406,11 +406,10 @@ def initialize(opts = {}) # load common methods extend Appium::Common extend Appium::Device + if device_is_android? - # load Android specific methods extend Appium::Android else - # load iOS specific methods extend Appium::Ios extend Appium::Ios::XcuitestGesture if automation_name_is_xcuitest? # Override touch actions end