[英]I want to find a similar API to org.sikuli.api.DesktopScreenRegion to verify if one image exists in another
I'm writing Python code for IOS automation using Appium, but get stuck on this issue: the check point is check some cells in tableView, when changing the device location setting (the cells will be different, both number and text), if the text and image appears in cell correctly, and the image matches the text, like football icon matches "football", I try to find webdriver api to capture the snapshot for the cell only, but all the methods I found are for the driver, it just can capture the whole screen. 我正在使用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
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;
}
}
this code can use imageExists to judge if the image can be found in another I search for sikuli api for python, but cannot find anything, looks like there's java api only now I'm stuck at this, could anyone help? 这段代码可以使用imageExists判断是否可以在另一个图像中找到该图像。我在python中搜索sikuli api,但是找不到任何东西,看起来只有Java api,现在我被困在这个位置,有人可以帮忙吗? Thanks a lot!
非常感谢!
Sikuli supports Jython as well. Sikuli也支持Jython。 In fact that is default the scripting language for Sikuli.
实际上,这是Sikuli的默认脚本语言。 So you can write similar logic in Jython and then call that script from Python(if at all you can).
因此,您可以在Jython中编写类似的逻辑,然后从Python调用该脚本(如果可以的话)。 I have seen users using Java to call sikuli script.
我已经看到用户使用Java来调用sikuli脚本。 Refer here for Sikuli details.
有关Sikuli的详细信息,请参阅此处 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.