4

I am testing an app that requires the user to send a picture of their ID to validate the creation of their account. Unfortunately, there isn't an option on the application itself to upload a picture directly from device storage, and I am doing the majority of my testing on an android virtual device (via android studio).

Is it possible to send a static picture to android studio when the camera opens up, which is saved on my local machine?

Looking for a way to do this fully from code only. (something like driver.getCurrentCamera().sendFile("/path/to/the/file"))

My framework uses Java.

This is exactly what I am looking to do, was unable to find an answer: https://discuss.appium.io/t/fake-the-camera-feed-with-a-file/7356/3

Similar to this, without saucelabs: https://www.youtube.com/watch?v=NmQ6BEjQBWs&feature=emb_title&ab_channel=SauceLabs (timestamp 0:37 onwards)

Sagol Goru
  • 43
  • 1
  • 4
  • Create a 'fake' webcam on your PC platform to feed into the [Android Emulator which can use a webcam as input](https://stackoverflow.com/a/8443673/295004) – Morrison Chang Nov 07 '20 at 04:16
  • Is there any way to do it fully from code only? – Sagol Goru Nov 07 '20 at 04:23
  • Not sure what you mean by "code only". OBS can be used as a virtual webcam. Or possibly [via command line on Linux](https://stackoverflow.com/a/35526103/295004). With effort perhaps you can upload images to the [emulator virtual environment](https://stackoverflow.com/a/55749661/295004) and use that. Alternately have the development team build in a debug mode where you can upload an image. – Morrison Chang Nov 07 '20 at 04:47
  • I have the steps to get to the point where the application opens the camera already in the framework. I want to send a picture from my local machine to the emulator camera, so that the emulator camera returns that picture to the application, as if it had taken it (basically fake the camera feed). What I mean by "code only" is can I do this purely from my framework alone (something like driver.getCurrentCamera().sendFile("/path/to/the/file"))? – Sagol Goru Nov 07 '20 at 05:18
  • You don't mention what framework you are using. If within an Android app, you'll have to push an image onto the external storage/SD card/injected via `adb` to be used by the Android app. See: [Android mock Camera](https://stackoverflow.com/q/18572130/295004) Otherwise you'll have to inject the image into the emulator via the two methods mentioned earlier. – Morrison Chang Nov 07 '20 at 05:32
  • Yes, this is within an android app. What would be the next step after pushing the image to the device via adb? – Sagol Goru Nov 07 '20 at 05:47

0 Answers0