拍照后,appium 找不到刻度线怎么办 select Ok?
After taking Picture, how to select Ok in appium when tick mark cant be located?
拍完照片后,appium 找不到刻度线怎么办?select
只有相机布局突出显示,我无法找到刻度线或还原。
请尝试以下代码片段。如果您能够使用 android 键盘点击,那么下面的代码应该可以工作。
((AndroidDriver)driver).pressKey(new KeyEvent(AndroidKey.SEARCH));
我使用 TouchAction 实现了这个。
TouchAction touchAction = new TouchAction(driver);
touchAction.tap(new PointOption().withCoordinates(111, 222)).perform()
solution for accepting image using camera app in appium.
keyEvent=>27, is use to capture the image using camera app.
我使用下面的代码来接受捕获的图像。 (但它不起作用)
i used keyEvent=> 66, Enter button to accept the image (but its not working).
i used keyEvent=> 84, Space button to accept the image (but its not working).
下面的工作代码。
i used keyEvent=> 22 and then i used keyEvent=> 66, it will accept the image.
$app.press_keycode(27) #click on camera accept button.
$app.press_keycode(22)
$app.press_keycode(66)
sleep 2
$app.press_keycode(27)
$app.press_keycode(22)
$app.press_keycode(66)
注意:重复2次的代码
i used keyEvent=> 21 and then i used keyEvent=> 66 and i used keyEvent=> 27, it will allow u to retake the image.
i used keyEvent=>4, it will take back u form camera app
我最初处理相机和勾选按钮的方式是使用 Android 按键代码:
Thread.sleep(2000);
androidDriver.pressKey(new KeyEvent(AndroidKey.CAMERA));
Thread.sleep(1000);
androidDriver.pressKey(new KeyEvent(AndroidKey.TAB));
Thread.sleep(1000);
androidDriver.pressKey(new KeyEvent(AndroidKey.TAB));
Thread.sleep(1000);
androidDriver.pressKey(new KeyEvent(AndroidKey.ENTER));
在我之前研究过的大多数设备中,上面的代码片段对我来说就像一个魅力。但是,当我最近开始在 Android 版本 9、10 和 11 上进行测试时,这不起作用,标签的数量增加到 3 或 4。要在三星、OnePlus 等大多数设备中处理此问题,Google Pixel,我将代码重构为:
Thread.sleep(2000);
// Click Camera shutter button
androidDriver.pressKey(new KeyEvent(AndroidKey.CAMERA));
try {
WebDriverWait wait = new WebDriverWait(androidDriver, 10);
wait.until(ExpectedConditions.elementToBeClickable((MobileBy.AccessibilityId("Done");
// Click Done or Tick after clicking photo (Mostly visible in OnePlus, Nokia, Google Pixel devices)
androidDriver.findElementByAccessibilityId("Done").click();
} catch (NoSuchElementException e) {
flag = true;
System.out.println("NoSuchElement for DONE Button");
}
if (flag) {
try {
// Click OK after clicking photo (Mostly visible in Samsung devices)
// No need to put WebDriverWait here as we already waited for 10 secs after clicking on Camera
androidDriver.findElementByXPath("//android.widget.TextView[@text='OK']").click();
flag = false;
System.out.println("OK Button Clicked");
} catch (NoSuchElementException e) {
flag = true;
System.out.println("NoSuchElement for OK Button");
}
}
if (flag) {
// If both above methods failed, then this may work (Mostly works for Xiaomi, Nokia devices)
androidDriver.pressKey(new KeyEvent(AndroidKey.TAB));
hardStopWait(1000);
androidDriver.pressKey(new KeyEvent(AndroidKey.TAB));
hardStopWait(1000);
androidDriver.pressKey(new KeyEvent(AndroidKey.ENTER));
System.out.println("TABS & ENTER Pressed");
}
拍完照片后,appium 找不到刻度线怎么办?select 只有相机布局突出显示,我无法找到刻度线或还原。
请尝试以下代码片段。如果您能够使用 android 键盘点击,那么下面的代码应该可以工作。
((AndroidDriver)driver).pressKey(new KeyEvent(AndroidKey.SEARCH));
我使用 TouchAction 实现了这个。
TouchAction touchAction = new TouchAction(driver); touchAction.tap(new PointOption().withCoordinates(111, 222)).perform()
solution for accepting image using camera app in appium.
keyEvent=>27, is use to capture the image using camera app.
我使用下面的代码来接受捕获的图像。 (但它不起作用)
i used keyEvent=> 66, Enter button to accept the image (but its not working).
i used keyEvent=> 84, Space button to accept the image (but its not working).
下面的工作代码。
i used keyEvent=> 22 and then i used keyEvent=> 66, it will accept the image.
$app.press_keycode(27) #click on camera accept button.
$app.press_keycode(22)
$app.press_keycode(66)
sleep 2
$app.press_keycode(27)
$app.press_keycode(22)
$app.press_keycode(66)
注意:重复2次的代码
i used keyEvent=> 21 and then i used keyEvent=> 66 and i used keyEvent=> 27, it will allow u to retake the image.
i used keyEvent=>4, it will take back u form camera app
我最初处理相机和勾选按钮的方式是使用 Android 按键代码:
Thread.sleep(2000);
androidDriver.pressKey(new KeyEvent(AndroidKey.CAMERA));
Thread.sleep(1000);
androidDriver.pressKey(new KeyEvent(AndroidKey.TAB));
Thread.sleep(1000);
androidDriver.pressKey(new KeyEvent(AndroidKey.TAB));
Thread.sleep(1000);
androidDriver.pressKey(new KeyEvent(AndroidKey.ENTER));
在我之前研究过的大多数设备中,上面的代码片段对我来说就像一个魅力。但是,当我最近开始在 Android 版本 9、10 和 11 上进行测试时,这不起作用,标签的数量增加到 3 或 4。要在三星、OnePlus 等大多数设备中处理此问题,Google Pixel,我将代码重构为:
Thread.sleep(2000);
// Click Camera shutter button
androidDriver.pressKey(new KeyEvent(AndroidKey.CAMERA));
try {
WebDriverWait wait = new WebDriverWait(androidDriver, 10);
wait.until(ExpectedConditions.elementToBeClickable((MobileBy.AccessibilityId("Done");
// Click Done or Tick after clicking photo (Mostly visible in OnePlus, Nokia, Google Pixel devices)
androidDriver.findElementByAccessibilityId("Done").click();
} catch (NoSuchElementException e) {
flag = true;
System.out.println("NoSuchElement for DONE Button");
}
if (flag) {
try {
// Click OK after clicking photo (Mostly visible in Samsung devices)
// No need to put WebDriverWait here as we already waited for 10 secs after clicking on Camera
androidDriver.findElementByXPath("//android.widget.TextView[@text='OK']").click();
flag = false;
System.out.println("OK Button Clicked");
} catch (NoSuchElementException e) {
flag = true;
System.out.println("NoSuchElement for OK Button");
}
}
if (flag) {
// If both above methods failed, then this may work (Mostly works for Xiaomi, Nokia devices)
androidDriver.pressKey(new KeyEvent(AndroidKey.TAB));
hardStopWait(1000);
androidDriver.pressKey(new KeyEvent(AndroidKey.TAB));
hardStopWait(1000);
androidDriver.pressKey(new KeyEvent(AndroidKey.ENTER));
System.out.println("TABS & ENTER Pressed");
}