我正在使用 Appium 编写用于 IOS 自动化的 Python 代码,但遇到了这个问题:检查点是在更改设备位置设置时检查 tableView 中的一些单元格(单元格将不同,包括数字和文本),如果文本和图像正确显示在单元格中,并且图像与文本匹配,例如足球图标匹配“足球”,我尝试找到 webdriver api 仅捕获单元格的快照,但我找到的所有方法都是针对驱动程序的,它只是可以捕获整个屏幕。
so we found a way to check this: first we capture the correct screenshot for the cells manually, then running the automation script, use the correct cell_screenshot to check if it appears in the screen
现在我的同事有这个的java代码:
import org.sikuli.api.DesktopScreenRegion;
import org.sikuli.api.ImageTarget;
import org.sikuli.api.ScreenRegion;
import org.sikuli.api.Target;
public class SnapShot {
static DesktopScreenRegion sr = new DesktopScreenRegion();
static Target image;
static ScreenRegion result;
static String fileURL;
private static String getImageURL(String fileURL){
return "screenshots/" + fileURL;
}`enter code here`
public static boolean imageExists(String fileURL, Double similar, int timeout){
timeout = timeout * 1000;
image = new ImageTarget(new File(getImageURL(fileURL)));
image.setMinScore(similar);
result = sr.wait(image, timeout);
if (result == null){
System.out.println("Can not find image");
return false;
}
return true;
}
}
此代码可以使用 imageExists 来判断图像是否可以在另一个中找到我搜索 sikuli api for python,但找不到任何东西,看起来只有 java api 现在我被困在这个问题上,有人可以帮忙吗?非常感谢!