appium_lib 0.6.7 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/appium_lib.gemspec +1 -1
- data/docs/android_docs.md +117 -109
- data/docs/docs.md +21 -0
- data/docs/ios_docs.md +116 -108
- data/lib/appium_lib/android/helper.rb +50 -14
- data/lib/appium_lib/common/version.rb +1 -1
- data/lib/appium_lib/driver.rb +5 -4
- data/lib/appium_lib/ios/helper.rb +24 -1
- data/readme.md +1 -1
- data/release_notes.md +10 -0
- metadata +3 -3
| @@ -307,6 +307,10 @@ module Appium::Android | |
| 307 307 | 
             
                nil
         | 
| 308 308 | 
             
              end
         | 
| 309 309 |  | 
| 310 | 
            +
              def lazy_load_strings
         | 
| 311 | 
            +
                @strings_xml ||= mobile(:getStrings)
         | 
| 312 | 
            +
              end
         | 
| 313 | 
            +
             | 
| 310 314 | 
             
              # Android only.
         | 
| 311 315 | 
             
              # Returns a string containing interesting elements.
         | 
| 312 316 | 
             
              # If an element has no content desc or text, then it's not returned by this method.
         | 
| @@ -325,33 +329,62 @@ module Appium::Android | |
| 325 329 | 
             
                    keys = node.keys
         | 
| 326 330 | 
             
                    return if keys.empty?
         | 
| 327 331 |  | 
| 332 | 
            +
                    n_content = '@content-desc'
         | 
| 333 | 
            +
                    n_text = '@text'
         | 
| 334 | 
            +
                    n_class = '@class'
         | 
| 335 | 
            +
                    n_resource = '@resource-id'
         | 
| 336 | 
            +
                    n_node = 'node'
         | 
| 337 | 
            +
             | 
| 328 338 | 
             
                    obj = {}
         | 
| 329 | 
            -
                    obj.merge!( { desc: node[ | 
| 330 | 
            -
                    obj.merge!( { text: node[ | 
| 331 | 
            -
                    obj.merge!( { class: node[ | 
| 339 | 
            +
                    obj.merge!( { desc: node[n_content] } ) if keys.include?(n_content) && !node[n_content].empty?
         | 
| 340 | 
            +
                    obj.merge!( { text: node[n_text] } ) if keys.include?(n_text) && !node[n_text].empty?
         | 
| 341 | 
            +
                    obj.merge!( { class: node[n_class] } ) if keys.include?(n_class) && !obj.empty?
         | 
| 342 | 
            +
                    obj.merge!( { resource_id: node[n_resource] } ) if keys.include?(n_resource) && !obj.empty?
         | 
| 332 343 |  | 
| 333 344 | 
             
                    r.push obj if !obj.empty?
         | 
| 334 | 
            -
                    run_internal.call node[ | 
| 345 | 
            +
                    run_internal.call node[n_node] if keys.include?(n_node)
         | 
| 335 346 | 
             
                  end
         | 
| 336 347 |  | 
| 337 348 | 
             
                  run_internal.call node
         | 
| 338 349 | 
             
                  r
         | 
| 339 350 | 
             
                end
         | 
| 340 351 |  | 
| 352 | 
            +
                lazy_load_strings
         | 
| 341 353 | 
             
                json = get_source
         | 
| 342 354 | 
             
                node = json['hierarchy']
         | 
| 343 355 | 
             
                results = run node
         | 
| 344 356 |  | 
| 345 357 | 
             
                out = ''
         | 
| 346 358 | 
             
                results.each { |e|
         | 
| 347 | 
            -
                   | 
| 348 | 
            -
             | 
| 349 | 
            -
                   | 
| 350 | 
            -
                   | 
| 351 | 
            -
             | 
| 359 | 
            +
                  e_desc = e[:desc]
         | 
| 360 | 
            +
                  e_text = e[:text]
         | 
| 361 | 
            +
                  e_class = e[:class]
         | 
| 362 | 
            +
                  e_resource_id = e[:resource_id]
         | 
| 363 | 
            +
                  out += e_class.split('.').last + "\n"
         | 
| 364 | 
            +
             | 
| 365 | 
            +
                  out += "  class: #{e_class}\n"
         | 
| 366 | 
            +
                  if e_text == e_desc
         | 
| 367 | 
            +
                    out += "  text, name: #{e_text}\n" unless e_text.nil?
         | 
| 352 368 | 
             
                  else
         | 
| 353 | 
            -
                    out += "  text: #{ | 
| 354 | 
            -
                    out += "  name: #{ | 
| 369 | 
            +
                    out += "  text: #{e_text}\n" unless e_text.nil?
         | 
| 370 | 
            +
                    out += "  name: #{e_desc}\n" unless e_desc.nil?
         | 
| 371 | 
            +
                  end
         | 
| 372 | 
            +
             | 
| 373 | 
            +
                  out += "  resource_id: #{e_resource_id}\n" unless e_resource_id.nil?
         | 
| 374 | 
            +
             | 
| 375 | 
            +
                  # there may be many ids with the same value.
         | 
| 376 | 
            +
                  # output all exact matches.
         | 
| 377 | 
            +
                  id_matches = @strings_xml.select do |key, value|
         | 
| 378 | 
            +
                    value == e_desc || value == e_text
         | 
| 379 | 
            +
                  end
         | 
| 380 | 
            +
             | 
| 381 | 
            +
                  if id_matches && id_matches.length > 0
         | 
| 382 | 
            +
                    match_str = ''
         | 
| 383 | 
            +
                    # [0] = key, [1] = value
         | 
| 384 | 
            +
                    id_matches.each do |match|
         | 
| 385 | 
            +
                      match_str += ' ' * 6 + "#{match[0]}\n"
         | 
| 386 | 
            +
                    end
         | 
| 387 | 
            +
                    out += "  id: #{match_str.strip}\n"
         | 
| 355 388 | 
             
                  end
         | 
| 356 389 | 
             
                }
         | 
| 357 390 | 
             
                out
         | 
| @@ -387,21 +420,24 @@ module Appium::Android | |
| 387 420 | 
             
              # @param target [String] the target to search for in strings.xml values
         | 
| 388 421 | 
             
              # @return [Array]
         | 
| 389 422 | 
             
              def xml_keys target
         | 
| 390 | 
            -
                 | 
| 423 | 
            +
                lazy_load_strings
         | 
| 424 | 
            +
                @strings_xml.select { |key, value| key.downcase.include? target.downcase }
         | 
| 391 425 | 
             
              end
         | 
| 392 426 |  | 
| 393 427 | 
             
              # Search strings.xml's keys for target.
         | 
| 394 428 | 
             
              # @param target [String] the target to search for in strings.xml keys
         | 
| 395 429 | 
             
              # @return [Array]
         | 
| 396 430 | 
             
              def xml_values target
         | 
| 397 | 
            -
                 | 
| 431 | 
            +
                lazy_load_strings
         | 
| 432 | 
            +
                @strings_xml.select { |key, value| value.downcase.include? target.downcase }
         | 
| 398 433 | 
             
              end
         | 
| 399 434 |  | 
| 400 435 | 
             
              # Resolve id in strings.xml and return the value.
         | 
| 401 436 | 
             
              # @param id [String] the id to resolve
         | 
| 402 437 | 
             
              # @return [String]
         | 
| 403 438 | 
             
              def resolve_id id
         | 
| 404 | 
            -
                 | 
| 439 | 
            +
                lazy_load_strings
         | 
| 440 | 
            +
                @strings_xml[id]
         | 
| 405 441 | 
             
              end
         | 
| 406 442 |  | 
| 407 443 | 
             
              # Lists package, activity, and adb shell am start -n value for current app.
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            # encoding: utf-8
         | 
| 2 2 | 
             
            module Appium
         | 
| 3 3 | 
             
              # Version and Date are defined on the 'Appium' module, not 'Appium::Common'
         | 
| 4 | 
            -
              VERSION = '0. | 
| 4 | 
            +
              VERSION = '0.7.0' unless defined? ::Appium::VERSION
         | 
| 5 5 | 
             
              DATE = '2013-08-23' unless defined? ::Appium::DATE
         | 
| 6 6 | 
             
            end
         | 
    
        data/lib/appium_lib/driver.rb
    CHANGED
    
    | @@ -194,7 +194,7 @@ module Appium | |
| 194 194 | 
             
                attr_reader :default_wait, :app_path, :app_name, :device,
         | 
| 195 195 | 
             
                            :app_package, :app_activity, :app_wait_activity,
         | 
| 196 196 | 
             
                            :sauce_username, :sauce_access_key, :port, :debug,
         | 
| 197 | 
            -
                            :export_session, :device_cap
         | 
| 197 | 
            +
                            :export_session, :device_cap, :compress_xml
         | 
| 198 198 |  | 
| 199 199 | 
             
                # The amount to sleep in seconds before every webdriver http call.
         | 
| 200 200 | 
             
                attr_accessor :global_webdriver_http_sleep
         | 
| @@ -234,6 +234,8 @@ module Appium | |
| 234 234 | 
             
                  # convert to downcased symbols
         | 
| 235 235 | 
             
                  opts.each_pair { |k,v| opts[k.to_s.downcase.strip.intern] = v }
         | 
| 236 236 |  | 
| 237 | 
            +
                  @compress_xml = opts[:compress_xml] ? true : false
         | 
| 238 | 
            +
             | 
| 237 239 | 
             
                  @export_session = opts.fetch :export_session, false
         | 
| 238 240 |  | 
| 239 241 | 
             
                  @default_wait = opts.fetch :wait, 30
         | 
| @@ -345,7 +347,7 @@ module Appium | |
| 345 347 | 
             
                # https://github.com/jlipps/appium/blob/master/app/android.js
         | 
| 346 348 | 
             
                def android_capabilities
         | 
| 347 349 | 
             
                  {
         | 
| 348 | 
            -
                     | 
| 350 | 
            +
                    compressXml: @compress_xml,
         | 
| 349 351 | 
             
                    platform: 'LINUX',
         | 
| 350 352 | 
             
                    version: '4.2',
         | 
| 351 353 | 
             
                    device: @device == :android ? 'Android' : 'selendroid',
         | 
| @@ -360,9 +362,8 @@ module Appium | |
| 360 362 | 
             
                # WebDriver capabilities. Must be valid for Sauce to work.
         | 
| 361 363 | 
             
                def ios_capabilities
         | 
| 362 364 | 
             
                  {
         | 
| 363 | 
            -
                    browserName: 'iOS 6.0',
         | 
| 364 365 | 
             
                    platform: 'Mac 10.8',
         | 
| 365 | 
            -
                    version: '6. | 
| 366 | 
            +
                    version: '6.1',
         | 
| 366 367 | 
             
                    device: @device_cap || 'iPhone Simulator',
         | 
| 367 368 | 
             
                    name: @app_name || 'Ruby Console iOS Appium'
         | 
| 368 369 | 
             
                  }
         | 
| @@ -83,11 +83,19 @@ module Appium::Ios | |
| 83 83 | 
             
                nil
         | 
| 84 84 | 
             
              end
         | 
| 85 85 |  | 
| 86 | 
            +
              def lazy_load_strings
         | 
| 87 | 
            +
                @strings_xml ||= mobile(:getStrings)
         | 
| 88 | 
            +
              end
         | 
| 89 | 
            +
             | 
| 86 90 | 
             
              # Returns a string of interesting elements. iOS only.
         | 
| 87 91 | 
             
              #
         | 
| 92 | 
            +
              # Defaults to inspecting the 1st windows source only.
         | 
| 93 | 
            +
              # use get_page(get_source) for all window sources
         | 
| 94 | 
            +
              #
         | 
| 88 95 | 
             
              # @param element [Object] the element to search. omit to search everything
         | 
| 89 96 | 
             
              # @return [String]
         | 
| 90 | 
            -
              def get_page element= | 
| 97 | 
            +
              def get_page element=source_window(0)
         | 
| 98 | 
            +
                lazy_load_strings
         | 
| 91 99 |  | 
| 92 100 | 
             
                # @private
         | 
| 93 101 | 
             
                def empty ele
         | 
| @@ -123,6 +131,21 @@ module Appium::Ios | |
| 123 131 | 
             
                    puts "  label: #{label}" if label
         | 
| 124 132 | 
             
                    puts "  value: #{value}" if value
         | 
| 125 133 | 
             
                  end
         | 
| 134 | 
            +
             | 
| 135 | 
            +
                  # there may be many ids with the same value.
         | 
| 136 | 
            +
                  # output all exact matches.
         | 
| 137 | 
            +
                  id_matches = @strings_xml.select do |key, val|
         | 
| 138 | 
            +
                    val == name || val == label || val == value
         | 
| 139 | 
            +
                  end
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                  if id_matches && id_matches.length > 0
         | 
| 142 | 
            +
                    match_str = ''
         | 
| 143 | 
            +
                    # [0] = key, [1] = value
         | 
| 144 | 
            +
                    id_matches.each do |match|
         | 
| 145 | 
            +
                      match_str += ' ' * 7 + "#{match[0]}\n"
         | 
| 146 | 
            +
                    end
         | 
| 147 | 
            +
                    puts "   id: #{match_str.strip}\n"
         | 
| 148 | 
            +
                  end
         | 
| 126 149 | 
             
                end
         | 
| 127 150 |  | 
| 128 151 | 
             
                children = element['children']
         | 
    
        data/readme.md
    CHANGED
    
    | @@ -4,7 +4,7 @@ | |
| 4 4 | 
             
            - [Documentation for appium_lib](http://www.rubydoc.info/github/appium/ruby_lib/master/frames)
         | 
| 5 5 | 
             
            - [Appium Ruby Console](https://github.com/appium/ruby_console)
         | 
| 6 6 |  | 
| 7 | 
            -
            Helper methods for writing cross platform ( | 
| 7 | 
            +
            Helper methods for writing cross platform (iOS, Android) tests in Ruby using Appium. Note that user waits should not exceed 120 seconds if they're going to run on Sauce Labs.
         | 
| 8 8 |  | 
| 9 9 | 
             
            Make sure you're using Ruby 1.9.3+ with upgraded rubygems and bundler.
         | 
| 10 10 |  | 
    
        data/release_notes.md
    CHANGED
    
    | @@ -1,3 +1,13 @@ | |
| 1 | 
            +
            #### v0.6.7 2013-08-23
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            - [a1f5942](https://github.com/appium/ruby_lib/commit/a1f5942e907339f1c3968c5af03feb5bde6b1b7c) Release 0.6.7
         | 
| 4 | 
            +
            - [4a08dd6](https://github.com/appium/ruby_lib/commit/4a08dd63add2fd11e7cbb7aadaa086f6fb014ed2) Enable bundleid in app device cap
         | 
| 5 | 
            +
            - [caff218](https://github.com/appium/ruby_lib/commit/caff2187c378e619ee5b4e0524734df372354b69) Improve docs
         | 
| 6 | 
            +
            - [b579ca7](https://github.com/appium/ruby_lib/commit/b579ca7fd83c6673be1f04d745b9d6cbdaeb6504) Add iOS Jenkins Xcode note
         | 
| 7 | 
            +
            - [4fbf0fb](https://github.com/appium/ruby_lib/commit/4fbf0fbdea07120ebf4d270bfee2cf251ba312fb) Add landscape and portrait rotate examples
         | 
| 8 | 
            +
            - [c6d4353](https://github.com/appium/ruby_lib/commit/c6d43537c759342b1ceed72cf8a81573c5070c65) Allow setting device cap
         | 
| 9 | 
            +
             | 
| 10 | 
            +
             | 
| 1 11 | 
             
            #### v0.6.6 2013-08-19
         | 
| 2 12 |  | 
| 3 13 | 
             
            - [5b84a0b](https://github.com/appium/ruby_lib/commit/5b84a0bd9d9273c704414bdb9a9857b503439b90) Release 0.6.6
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: appium_lib
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.7.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - code@bootstraponline.com
         | 
| @@ -16,14 +16,14 @@ dependencies: | |
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - ~>
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: 2. | 
| 19 | 
            +
                    version: 2.35.1
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 24 | 
             
                - - ~>
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version: 2. | 
| 26 | 
            +
                    version: 2.35.1
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: awesome_print
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         |