Click on capture image button of camera


#1

Hi, i am using AppiumForWindows-1.2.4.1, 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();”.

Regards,
Saurav


#2

Have you tried sending key event KEYCODE_CAMERA ?


#3

Hi,

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


#4

try tab on screen coordinates (Just a workaround)


#5

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


#6

HI @Telmo_Cardoso,

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

Thanks,
Bhaskar.


#7

Hi,

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


#8

#9

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


#10

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

“com.sec.android.app.camera:id/save”, “com.sec.android.app.camera:id/okay”

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


#11

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);
Thread.sleep(5000);
driver.findElement(By.xpath("//android.widget.Button[contains(@resource-id,‘okay’)]")).click();


#12

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:-

driver.sendKeyEvent(KeyEvent.KEYCODE_CAMERA);
d.pressKeyCode(AndroidKeyCode.KEYCODE_CAMERA);

but on my eclispe its showing error while appending kecode


#13

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?


#15

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 !!!


#16

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


#17

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.