Click on capture image button of camera

Hi, i am using AppiumForWindows-, java-client-2.1.0 and Java with eclipse to do automation for a Android devices. I am not able to find a way to click on capture button of the camera.

Is there any shortcut for capture?

As we have for back button “driver.navigate().back();”.


Have you tried sending key event KEYCODE_CAMERA ?


I searched for “if we can detect the camera button on screen of android device”?
Unfortunately, nothing found but for solution, KEYCODE_CAMERA is suggested in most.

Is there any alternative solution?

I want to capture the photo and video but I dont find the element locators there on the screen to proceed.
Tried appium inspector too but no luck so far. Please share the possible solutions.

@sujata_kalluri @jonahss @Hassan_Radi @Appium_Master

try tab on screen coordinates (Just a workaround)

You using native camera app? Whats the device you testing. So far I haven’t had any problem with native apps (contacts, dialer, camera, etc.). Only problem is that each manufacturer has their own resource ids

HI @Telmo_Cardoso,

Could you please elaborate How to automate Camera App on Samsung device Galaxy S5?



never tested on Galaxy S5. But if when you open camera and you go to inspector you cannot see anything, then try:

press_keycode 27

To take a photo, and

press_keycode 4

to go back to where you were. This is using ruby… but same principle will work for java, just look for proper code to send keys

1 Like

[quote=“Telmo_Cardoso, post:7, topic:3173”]
After taking Picture, how to select Ok or Cancel button? Thank you

Follow steps to identify the save camera button identifier

  1. Open camera
  2. Take picture
  3. Go to UIAutomator and check the identity of the tick mark sign. It will be something like e.g., Samsung devices

“”, “”

depending upon OS and device. For google nexus it can be different

  1. Note this

Program it

use identifier in your program to click on the identifier you just noted down

Hope that helps

For Samsung s5 please use coordinates to click on capture button in camera view.
HashMap<String, Double> map = new HashMap<String, Double>();
map.put(“x”, 0.5);
map.put(“y”, 0.9); // To select Y axis (0.7)
(driver).executeScript(“mobile: tap”, map);

I m checking the skype app functionality . and trying to change the
profile pic of it. i tried two queries.But android device is not
capturing the image.

i tried two queries:-


but on my eclispe its showing error while appending kecode

The problem we need to resolve is when we capture this photo, it’ll appear 2 button, back button and OK button, and it’s different each other devices, how can we handle it?

I have the same problem now.
Just now I am writing a test that is supposed to activate the camera, take a picture and click On OK button. The problem is that the automation test I write will run on a large number of devices and each has a different OK button ID. Did you solve the problem?

Thanks !!!

1 Like

If its android : use Activity name to open the camera app and abd command to capture photos

How many # of combinations would you have for devices. Either that will be having OK button or Done or a tick-mark. You can put all such unique attributes in your page object and check if any one of them is available and click on that after taking the picture.

Hi! I am running into the same issue with my tests. I need to take a picture as a part of the process but while testing it on a large range of Android devices/operating systems I am running into a big inconsistency issue. Each device and operating system has different pop ups and different ID’s to confirm the picture. Have you found any solutions?

Using below code snippet to capture photo, it is working. .

((AndroidDriver<?>) driver).pressKey(new KeyEvent(AndroidKey.CAMERA));

Here my question what is the keycode to select captured photo?

KeyEvents list here AndroidKeys

Download OpenCamera from the PlayStore

Then you will only need to send keycode 27 once

Did you get the answer for this?