Fake the camera feed with a file

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!

4 Likes

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

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

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

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

1 Like

Hi
Does someone find any solutions ?

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

1 Like

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

1 Like

I am looking for the same. is there any solution?

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

Did u find any solution?

Hello @Or_Amoyal

Did you get the solution?

I have never met anywhere that you can fool the camera on a real device. It seems that in this case, in principle, the meaning of the functionality of the camera is lost.
The only thing that comes to mind for your problem is to aim the device’s camera at the monitor screen (fix the device somehow), well, the first step is to display the picture on the monitor, the second step is to photograph with your application.
Everything is perfectly automated, except for installing the device in front of the monitor).

If not a real device, you can try on emulators. In the latest APIs, camera support has been made in emulators, you can set up a video stream from your webcam, I think you can also transfer static images in a similar way.

1 Like