Skip to content

Commit 14bcd8f

Browse files
Fix device cap
1 parent b4cb13c commit 14bcd8f

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

lib/appium_lib/android/helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ def run node
401401
# Returns a string containing interesting elements.
402402
# @return [String]
403403
def get_inspect
404-
@device == :selendroid ? get_selendroid_inspect : get_android_inspect
404+
@device == 'Selendroid' ? get_selendroid_inspect : get_android_inspect
405405
end
406406

407407
# Intended for use with console.

lib/appium_lib/driver.rb

+19-14
Original file line numberDiff line numberDiff line change
@@ -292,19 +292,24 @@ def initialize opts={}
292292

293293
@port = opts.fetch :port, ENV['PORT'] || 4723
294294

295-
# device as used in device capabilities.
296-
# iOS only.
295+
# 'iPhone Simulator'
296+
# 'iPad Simulator'
297+
# 'Android'
298+
# 'Selendroid'
297299
#
298-
# Android is always Android or Selendroid so there's no
299-
# override required.
300-
@device_cap = opts.fetch :device_cap, 'iPhone Simulator'
301-
302300
# :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)
305310

306311
@version = opts[:version]
307-
if @device == :android || @device == :selendroid
312+
if @device == 'Android' || @device == 'Selendroid'
308313
@version = '4.3' unless @version # default android to 4.3
309314
else
310315
@version = '7' unless @version # default ios to 7
@@ -315,7 +320,7 @@ def initialize opts={}
315320

316321
# load common methods
317322
extend Appium::Common
318-
if @device == :android
323+
if @device == 'Android'
319324
raise 'APP_ACTIVITY must be set.' if @app_activity.nil?
320325

321326
# load Android specific methods
@@ -387,7 +392,7 @@ def android_capabilities
387392
compressXml: @compress_xml,
388393
platform: 'Linux',
389394
version: @version,
390-
device: @device == :android ? 'Android' : 'selendroid',
395+
device: @device,
391396
:'device-type' => @device_type,
392397
:'device-orientation' => @device_orientation,
393398
name: @app_name || 'Ruby Console Android Appium',
@@ -404,15 +409,15 @@ def ios_capabilities
404409
{
405410
platform: 'OS X 10.9',
406411
version: @version,
407-
device: @device_cap,
412+
device: @device,
408413
name: @app_name || 'Ruby Console iOS Appium',
409414
:'device-orientation' => @device_orientation
410415
}
411416
end
412417

413418
# @private
414419
def capabilities
415-
caps = @device == :ios ? ios_capabilities : android_capabilities
420+
caps = ['iPhone Simulator', 'iPad Simulator'].include?(@device) ? ios_capabilities : android_capabilities
416421
caps[:app] = absolute_app_path unless @app_path.nil? || @app_path.empty?
417422
caps
418423
end
@@ -507,7 +512,7 @@ def start_driver
507512
# Set timeout to a large number so that Appium doesn't quit
508513
# when no commands are entered after 60 seconds.
509514
# 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'
511516

512517
# Set implicit wait by default unless we're using Pry.
513518
@driver.manage.timeouts.implicit_wait = @default_wait unless defined? Pry

0 commit comments

Comments
 (0)