@@ -292,19 +292,24 @@ def initialize opts={}
292
292
293
293
@port = opts . fetch :port , ENV [ 'PORT' ] || 4723
294
294
295
- # device as used in device capabilities.
296
- # iOS only.
295
+ # 'iPhone Simulator'
296
+ # 'iPad Simulator'
297
+ # 'Android'
298
+ # 'Selendroid'
297
299
#
298
- # Android is always Android or Selendroid so there's no
299
- # override required.
300
- @device_cap = opts . fetch :device_cap , 'iPhone Simulator'
301
-
302
300
# :ios, :android, :selendroid
303
- @device = opts . fetch :device , ENV [ 'DEVICE' ] || :ios
304
- @device = @device . to_s . downcase . intern # device must be a symbol
301
+ @device = opts [ :device ]
302
+ raise 'Device must be set' unless @device
303
+
304
+ @device = 'Android' if @device . to_s == 'android'
305
+ @device = 'Selendroid' if @device . to_s == 'selendroid'
306
+ @device = 'iPhone Simulator' if @device . to_s == 'ios'
307
+
308
+ raise 'Device must be set iPhone Simulator, iPad Simulator, Android' unless @device &&
309
+ [ 'iPhone Simulator' , 'iPad Simulator' , 'Android' , 'Selendroid' ] . include? ( @device )
305
310
306
311
@version = opts [ :version ]
307
- if @device == :android || @device == :selendroid
312
+ if @device == 'Android' || @device == 'Selendroid'
308
313
@version = '4.3' unless @version # default android to 4.3
309
314
else
310
315
@version = '7' unless @version # default ios to 7
@@ -315,7 +320,7 @@ def initialize opts={}
315
320
316
321
# load common methods
317
322
extend Appium ::Common
318
- if @device == :android
323
+ if @device == 'Android'
319
324
raise 'APP_ACTIVITY must be set.' if @app_activity . nil?
320
325
321
326
# load Android specific methods
@@ -387,7 +392,7 @@ def android_capabilities
387
392
compressXml : @compress_xml ,
388
393
platform : 'Linux' ,
389
394
version : @version ,
390
- device : @device == :android ? 'Android' : 'selendroid' ,
395
+ device : @device ,
391
396
:'device-type' => @device_type ,
392
397
:'device-orientation' => @device_orientation ,
393
398
name : @app_name || 'Ruby Console Android Appium' ,
@@ -404,15 +409,15 @@ def ios_capabilities
404
409
{
405
410
platform : 'OS X 10.9' ,
406
411
version : @version ,
407
- device : @device_cap ,
412
+ device : @device ,
408
413
name : @app_name || 'Ruby Console iOS Appium' ,
409
414
:'device-orientation' => @device_orientation
410
415
}
411
416
end
412
417
413
418
# @private
414
419
def capabilities
415
- caps = @device == :ios ? ios_capabilities : android_capabilities
420
+ caps = [ 'iPhone Simulator' , 'iPad Simulator' ] . include? ( @device ) ? ios_capabilities : android_capabilities
416
421
caps [ :app ] = absolute_app_path unless @app_path . nil? || @app_path . empty?
417
422
caps
418
423
end
@@ -507,7 +512,7 @@ def start_driver
507
512
# Set timeout to a large number so that Appium doesn't quit
508
513
# when no commands are entered after 60 seconds.
509
514
# broken on selendroid: https://github.com/appium/appium/issues/513
510
- mobile :setCommandTimeout , timeout : 9999 unless @device == :selendroid
515
+ mobile :setCommandTimeout , timeout : 9999 unless @device == 'Selendroid'
511
516
512
517
# Set implicit wait by default unless we're using Pry.
513
518
@driver . manage . timeouts . implicit_wait = @default_wait unless defined? Pry
0 commit comments