我必须在使用原生相机的Android和iOS上自动化Webapp。是否有可能使用量角器,appium和selenium Webdriver?
答案 0 :(得分:0)
我相信是的,你可以
参考以下文章: -
http://testingalert.com/automate-android-actions-using-appium/
以下是java代码。您只需要在protector nodeJS
中找到类似的操作public static void keyBoardEvent(int eventNumber)
{
try
{
Runtime.getRuntime().exec("cmd /C adb shell input keyevent " + eventNumber);
Thread.sleep(3000);
} catch (Throwable t)
{
t.printStackTrace();
}
}
By passing the eventNumber, we are able to perform desired event.
For Camera Click, Event Number is 27.
Camera Click implementation: -
public void clickCamera()
{
Keywords.keyBoardEvent(27);
System.out.print("Clicked on Camera ");
}
答案 1 :(得分:0)
显示“相机”按钮时,您可以运行以下代码:
try {
Runtime.getRuntime().exec("adb shell input `keyevent` 27");
Thread.sleep(2000);
} catch (Throwable t) {
t.printStackTrace();
}
无法触发相机。
答案 2 :(得分:-1)
点击应用程序元素后,您会转到相机或画廊选项
driver.findElement(
By.xpath(
"//android.widget.FrameLayout//android.widget.TextView[@text='Camera']"
)).click();
它将适用于从棉花糖到馅饼的所有设备
然后
try {
Runtime.getRuntime().exec("adb shell input `keyevent` 'KEYCODE_VOLUME_DOWN'");
Thread.sleep(2000);
} catch (Throwable t) {
t.printStackTrace();
}
或
try {
Runtime.getRuntime().exec("adb shell input `keyevent` 27");
Thread.sleep(2000);
} catch (Throwable t) {
t.printStackTrace();
}
它将单击相机快门按钮
然后,您必须选择已完成的选项,才能继续在各个设备上使用这些xpath
xpath = "//android.widget.ImageButton[@id='shutter_button']"; //(for google camera)
id = "okay"; //(samsung devices)
id = "com.android.camera2:id/done_button"; //(google pixel camera)
如果该元素没有定位符,则使用此
try {
Runtime.getRuntime().exec("adb shell input `keyevent` 'KEYCODE_VOLUME_UP'");
Thread.sleep(2000);
} catch (Throwable t) {
t.printStackTrace();
}
该控件将返回到本机应用程序