Search code examples
androidcirclecicalabash-android

Calabash-android select image from the device library


I am running calabash-android test for an android application. I need to attach images and videos to a particular section. I can reach the gallery section and after that, I could not select an item from the device library. Is there any way to keep a copy of video and image in my test directory and access the whenever needed? Or is there any solution to access the gallery. And one more thing is that I am integrating the test on Circle-ci later. And I don't know how can I manage it when it is on Circle-ci. All kind of help is appreciated.


Solution

  • Calabash only has access to your app, not anything outside of it.

    You will be able to put together a solution using adb to interact with the screen, using touch or keyboard events. However, this will be tied to one specific screen size, as it's done by pixels.

    adb shell input tap x y
    

    You could put the images/videos in the directory so they are the most recent, then use adb touch events to select them? It's a bit hacky but it should work.

    If I've understood your question correctly, the circle ci part should probably be split out into another question, as it isn't really tied to the previous bit.

    EDIT: We ended up getting it to work by running

    `adb shell input tap 200 200`