lib/appium_lib/driver.rb in appium_lib-0.3.7 vs lib/appium_lib/driver.rb in appium_lib-0.3.8

- old
+ new

@@ -34,11 +34,11 @@ class Driver @@loaded = false attr_reader :app_path, :app_name, :app_package, :app_activity, :app_wait_activity, :sauce_username, :sauce_access_key, - :port, :os, :ios_js + :port, :os, :ios_js, :debug def initialize options={} # quit last driver $driver.driver_quit if $driver opts = {} @@ -74,11 +74,10 @@ @port = opts.fetch :port, ENV['PORT'] || 4723 @os = :ios @os = :android if @app_path.end_with?('.apk') || @app_path.end_with?('.apk.zip') - puts "OS is: #{@os}" if defined?(Pry) # load common methods extend Appium::Common if @os == :android raise 'APP_ACTIVITY must be set.' if @app_activity.nil? @@ -93,12 +92,17 @@ # apply os specific patches patch_webdriver_element # enable debug patch - patch_webdriver_bridge if opts.fetch :debug, defined?(Pry) + @debug = opts.fetch :debug, defined?(Pry) + if @debug + puts "OS is: #{@os}" + patch_webdriver_bridge + end + # Save global reference to last created Appium driver for top level methods. $driver = self # Promote exactly once the first time the driver is created. # Subsequent drivers do not trigger promotion. @@ -119,11 +123,11 @@ # https://github.com/jlipps/appium/blob/master/app/android.js def android_capabilities { browserName: 'Android', platform: 'LINUX', - version: '4.1', + version: '4.2', device: @selendroid || 'Android', name: @app_name || 'Ruby Console Android Appium', app: absolute_app_path, :'app-package' => @app_package, :'app-activity' => @app_activity, @@ -201,16 +205,19 @@ @default_wait = wait begin @driver = Selenium::WebDriver.for :remote, http_client: @client, desired_capabilities: capabilities, url: server_url + # Load touch methods. Required for Selendroid. + @driver.extend Selenium::WebDriver::DriverExtensions::HasTouchScreen rescue Errno::ECONNREFUSED raise 'ERROR: Unable to connect to Appium. Is the server running?' end # Set timeout to a large number so that Appium doesn't quit # when no commands are entered after 60 seconds. - mobile :setCommandTimeout, timeout: 9999 + # broken on selendroid: https://github.com/appium/appium/issues/513 + mobile :setCommandTimeout, timeout: 9999 unless @selendroid # Set implicit wait by default unless we're using Pry. @driver.manage.timeouts.implicit_wait = @default_wait unless defined? Pry @driver