Class: ParallelAppium::Android
- Inherits:
-
Object
- Object
- ParallelAppium::Android
- Defined in:
- lib/parallel_appium/android.rb
Overview
Connecting to Android devices
Instance Method Summary collapse
-
#devices ⇒ Object
Devices after cleanup and supplemental data included.
-
#get_android_device_data(udid) ⇒ Object
Get additional information for the Android device with unique identifier udid.
-
#start_emulators ⇒ Object
Fire up the Android emulators.
Instance Method Details
#devices ⇒ Object
Devices after cleanup and supplemental data included
27 28 29 30 31 32 33 34 35 |
# File 'lib/parallel_appium/android.rb', line 27 def devices emulators = start_emulators sleep 10 devices = `adb devices`.split("\n").select { |x| x.include? "\tdevice" }.map.each_with_index { |d, i| {avd: emulators[i], platform: 'android', name: 'android', udid: d.split("\t")[0], wdaPort: 8100 + i, thread: i + 1} } devices = devices.map { |x| x.merge(get_android_device_data(x[:udid])) } ENV['DEVICES'] = JSON.generate(devices) devices end |
#get_android_device_data(udid) ⇒ Object
Get additional information for the Android device with unique identifier udid
16 17 18 19 20 21 22 23 24 |
# File 'lib/parallel_appium/android.rb', line 16 def get_android_device_data(udid) specs = { os: 'ro.build.version.release', manufacturer: 'ro.product.manufacturer', model: 'ro.product.model', sdk: 'ro.build.version.sdk' } hash = {} specs.each do |key, spec| value = `adb -s #{udid} shell getprop "#{spec}"`.strip hash.merge!(key => value.to_s) end hash end |
#start_emulators ⇒ Object
Fire up the Android emulators
5 6 7 8 9 10 11 12 13 |
# File 'lib/parallel_appium/android.rb', line 5 def start_emulators emulators = `emulator -list-avds`.split("\n") emulators = emulators[0, ENV['THREADS'].to_i] Parallel.map(emulators, in_threads: emulators.size) do |emulator| spawn("emulator -avd #{emulator} -no-snapshot-load -scale 100dpi -no-boot-anim -no-audio -accel on &", out: '/dev/null') end emulators end |