Fake the camera feed with a file


#1

Hi,
I have an app that opens the camera feed. After opening the camera, it waits for some kind of image, if it recognizes the image its waiting for its a success otherwise a failure.

I want to write a test that automates this for me, so is there any way by which i can send a image file its waiting via the appium android driver?

Test device: Samsung Galaxy Note 4

I would really appreciate any inputs!!

Thanks!


#2

There may be a much better way so I’ll let others chime in.

This logic obviously just creates a dummy file to attach.
But you can get access to your host computer’s terminal and do all sorts of activities to retrieve your desired filename.
Then you push to adb.

Here’s what I do:

  #Push a file from the host to the device
        system("mkdir -p /tmp")
        system("touch /tmp/myfile")
        system("adb push '/tmp/myfile' '/sdcard/0'")

The file system somewhat depends. You could also replace the above with /mnt/sdcard/0 and see if that works.

On iOS, I’m not sure if this is even possible as the Camera Roll is read Only.

Alternatively you could link a dropbox or google drive account and somehow access your pictures that way.

Hope this helps and good luck!
Eric


#3

Thanks for your reply Eric.
Here is what I did,
adb push /path/to/my/image /mnt/sdcard/Pictures
It pushes the file to device, Now I want my test case to feed this image file to the camera (which is currently opened in my app) so that my test case can proceed. Is this something possible with Appium, like it gets the current running camera instance and give a particular file as input? something like driver.getCurrentCamera().sendFile("/path/to/the/file") ?

Hope its clear enough.
Sumit


#4

I see. That I don’t know.
Would it be acceptable to automate the actual taking of a picture and have that be your image?
Otherwise, sorry I’m out of ideas :smile:
Good luck


#5

Hi,
did anyone get a solution to this?
I also want my automation script to push an image to the camera which is opened in the AUT (app under test).
Is there any way to do so in Android?
Any help will be highly appreciated


#6

Hi
Does someone find any solutions ?


#7

Have you guys find nay solution for this.Iam looking for a solution too…please help


#8

I’m looking for the same solution. Any ideas would be highly useful