lib/appium_lib/driver.rb in appium_lib-0.18.0 vs lib/appium_lib/driver.rb in appium_lib-0.18.1

- old
+ new

@@ -290,34 +290,39 @@ # Sauce Key @sauce_access_key = opts.fetch :sauce_access_key, ENV['SAUCE_ACCESS_KEY'] @port = opts.fetch :port, ENV['PORT'] || 4723 - # device as used in device capabilities. - # iOS only. + # 'iPhone Simulator' + # 'iPad Simulator' + # 'Android' + # 'Selendroid' # - # Android is always Android or Selendroid so there's no - # override required. - @device_cap = opts.fetch :device_cap, 'iPhone Simulator' - # :ios, :android, :selendroid - @device = opts.fetch :device, ENV['DEVICE'] || :ios - @device = @device.to_s.downcase.intern # device must be a symbol + @device = opts[:device] + raise 'Device must be set' unless @device + @device = 'Android' if @device.to_s == 'android' + @device = 'Selendroid' if @device.to_s == 'selendroid' + @device = 'iPhone Simulator' if @device.to_s == 'ios' + + raise 'Device must be set iPhone Simulator, iPad Simulator, Android' unless @device && + ['iPhone Simulator', 'iPad Simulator', 'Android', 'Selendroid'].include?(@device) + @version = opts[:version] - if @device == :android || @device == :selendroid + if @device == 'Android' || @device == 'Selendroid' @version = '4.3' unless @version # default android to 4.3 else @version = '7' unless @version # default ios to 7 end @device_type = opts.fetch :device_type, 'tablet' @device_orientation = opts.fetch :device_orientation, 'portrait' # load common methods extend Appium::Common - if @device == :android + if @device == 'Android' raise 'APP_ACTIVITY must be set.' if @app_activity.nil? # load Android specific methods extend Appium::Android else @@ -385,11 +390,11 @@ def android_capabilities { compressXml: @compress_xml, platform: 'Linux', version: @version, - device: @device == :android ? 'Android' : 'selendroid', + device: @device, :'device-type' => @device_type, :'device-orientation' => @device_orientation, name: @app_name || 'Ruby Console Android Appium', :'app-package' => @app_package, :'app-activity' => @app_activity, @@ -402,19 +407,19 @@ # WebDriver capabilities. Must be valid for Sauce to work. def ios_capabilities { platform: 'OS X 10.9', version: @version, - device: @device_cap, + device: @device, name: @app_name || 'Ruby Console iOS Appium', :'device-orientation' => @device_orientation } end # @private def capabilities - caps = @device == :ios ? ios_capabilities : android_capabilities + caps = ['iPhone Simulator', 'iPad Simulator'].include?(@device) ? ios_capabilities : android_capabilities caps[:app] = absolute_app_path unless @app_path.nil? || @app_path.empty? caps end # Converts environment variable APP_PATH to an absolute path. @@ -505,10 +510,10 @@ end # Set timeout to a large number so that Appium doesn't quit # when no commands are entered after 60 seconds. # broken on selendroid: https://github.com/appium/appium/issues/513 - mobile :setCommandTimeout, timeout: 9999 unless @device == :selendroid + mobile :setCommandTimeout, timeout: 9999 unless @device == 'Selendroid' # Set implicit wait by default unless we're using Pry. @driver.manage.timeouts.implicit_wait = @default_wait unless defined? Pry @driver \ No newline at end of file