Search code examples
androidautomated-testscalabashui-testing

How I can simulate user's activity system wide on Android device?


I'm writing automated tests to my application with Calabash-framework.

In some cases I need to start camera and perfrom some actions like take photo or record video. To do these actions I need to find and tap button in camera application but Calabash provides interaction only with test application.

So, here is the question: are there any frameworks or something else which can provide simulatiig user's actions system wide?


Solution

  • If you want to interact system or third party app means better options is Android UIautomator.

    It can simulate user action on across android device applications and you can find more info here

    Following tools are wrapped Android UI Automator to make easy to use it.

    1. Appium - website
    2. Python UI Automator - github link

    There is three way you can achive your goal,

    1. you may use any one of tool which is mentioned above then you need to rewrite entier scripts

    2. If you don't want rewrite entier scripts, still you need to use python uiautomator. Basically you need to write python scripts for system & third party apps interactions then you need to call that python file in your ruby code like this :

      system 'python file_path/file_name.py'

    3. Last options is, if your action is very minimal out of your core application then you need to use ADB commands which very simple and easy to use, for example I need to open camera, foucus and take picture use following command:

      system 'adb shell "am start -a android.media.action.IMAGE_CAPTURE"'
      system 'adb shell "input keyevent KEYCODE_FOCUS"'
      system 'adb shell "input keyevent KEYCODE_CAMERA"'
      

    In your case calabash-android wrapped with Android instrumentation framework.

    Calabash will resign your specific apk and tests are running againts that apk, so no way calabash can automate the other app using calabash commands. you may ended with any one of the option which I mentioned above.