android - Tests fail when device screen is sleeping -


i trying run calabash tests on android device. if manually turn screen before running tests works. on nexus 4 if turn screen off , try run tests first scenario times out waiting elements appear. on galaxy nexus if start tests screen off calabash wakes device , tests pass.

are there devices calabash cannot wake up? nexus 4 1 of these? turning on devices manually not feasible since run these tests on many devices.

i have found outdated references issue. post 2012 adam niedzielski @ https://groups.google.com/forum/#!topic/calabash-android/o6luueougte suggests following hook in app_life_cycle_hooks.rb

include calabash::android::operations  afterconfiguration |config|   wake_up end 

but code added ruby-gem/bin/calabash-android in calabash explicitly disallows inclusion of operations module: https://github.com/calabash/calabash-android/commit/995daef9b6636e7e4e572aeb5d4f90d6d072320f guess no longer recommended approach. if remove include , type calabash::android::operations.wake_up nameerror.

i've run error , ended setting screen timeout longer minute , running method before starting tests:

  def self.turn_on_screen(device_serial_number)     # switches on android devices screen if isn’t on.     if `adb -s #{device_serial_number} shell dumpsys input_method | grep mscreenon`.include? 'false'       `adb -s #{device_serial_number} shell input keyevent keycode_power`     end   end 

this turn simulate keypress of power button if screen isn't on. i've used on 4 different devices , not had issues far it'll work you.

it may worth noting i've turned lockscreens off the devices.

edit: after update lollipop had add in check. using both seems trick on of test devices.

if `adb shell dumpsys input_method | grep minteractive`.include? 'false'   `adb shell input keyevent keycode_power` end 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -