繁体   English   中英

我想找到与org.sikuli.api.DesktopScreenRegion类似的API,以验证另一个图像中是否存在一个图像

[英]I want to find a similar API to org.sikuli.api.DesktopScreenRegion to verify if one image exists in another

我正在使用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判断是否可以在另一个图像中找到该图像。我在python中搜索sikuli api,但是找不到任何东西,看起来只有Java api,现在我被困在这个位置,有人可以帮忙吗? 非常感谢!

Sikuli也支持Jython。 实际上,这是Sikuli的默认脚本语言。 因此,您可以在Jython中编写类似的逻辑,然后从Python调用该脚本(如果可以的话)。 我已经看到用户使用Java来调用sikuli脚本。 有关Sikuli的详细信息,请参阅此处

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM