[英]Why Sikuli is not able to find the image path
I am trying to open simple gmail link on google home page but image path is not getting detected by Sikuli here please help and yes I am working on Mac OS system.我正在尝试在 google 主页上打开简单的 gmail 链接,但 Sikuli 未在此处检测到图像路径,请帮助,是的,我正在使用 Mac OS 系统。 Is it something to do with my
sikulixapi
jar placement?这与我的
sikulixapi
jar 放置有关吗? I have placed it here:我把它放在这里:
/Users/vishalsrivastava/Documents/JARS/SikuliJar/sikulixapi.jar
and no matter what image or what path I am trying, Sikuli always returns error and exceptions.无论我尝试什么图像或路径,Sikuli 总是返回错误和异常。 I am totally confused.
我完全糊涂了。
package sikuli;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.sikuli.script.*;
public class TestSikuli {
public static void main(String[] args) {
WebDriver driver=new FirefoxDriver();
driver.get("http://google.com/");
driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
Screen s = new Screen();
try{
Pattern gmail=new Pattern("/Users/vishalsrivastava/Documents/workspace/SeleniumTest/imgs/gmail.png");
s.click(gmail);
}
catch(FindFailed e){
e.printStackTrace();
}
}
}
Your problem here does not seem to be the path. 您的问题似乎不是路径。 You can see what you get is the Sikuli
FindFailed
exception which means that the pattern you are looking for was not found on the screen or region. 您可以看到得到的是Sikuli
FindFailed
异常,这意味着在屏幕或区域中找不到所需的模式。
You have to ensure that the pattern you are looking for is actually on the screen. 您必须确保要查找的图案实际上在屏幕上。 Few things to check are:
要检查的几件事是:
EDIT : If you want to know for sure what is the path used by Sikuli, you can print it out like this: 编辑 :如果您想确定Sikuli使用的路径是什么,可以像这样打印出来:
System.out.println(ImagePath.getBundlePath());
I think 'Eugene S' is giving some usefull tips, but I would like to add something to it. 我认为'Eugene S'提供了一些有用的提示,但我想在此添加一些内容。
You can use .focusedWindow()
to locate the window that has focus/is in front. 您可以使用
.focusedWindow()
来定位具有焦点/在前面的窗口。
Next I find .highlight()
usefull as well, because it gives an idea where Sikuli is focusing on when looking for some image. 接下来,我发现
.highlight()
有用的,因为它给出了Sikuli在查找某些图像时将重点放在哪里的想法。
I use it a little bit for some fast debugging I guess. 我想我会用它来进行一些快速调试。
As Eugene and Tenzin mention, there are numerous reasons an image may not be found.正如 Eugene 和 Tenzin 所提到的,可能找不到图像的原因有很多。 In typical GUI automation, you need to figure this out by trial-and-error.
在典型的 GUI 自动化中,您需要通过反复试验来解决这个问题。
Since the images we choose have a large impact on the success of our automation, it is important to choose them wisely.由于我们选择的图像对我们自动化的成功有很大影响,因此明智地选择它们很重要。 Optimally, we would do an analysis of our images on our target environment before writing any code.
理想情况下,我们会在编写任何代码之前对目标环境中的图像进行分析。 Knowing, before we start coding, if images are found, if they are found in multiple places, in which locations and in which states of our environment they are found, can save us a lot of time and frustration down the line.
知道,在我们开始编码之前,如果找到图像,是否在多个地方找到它们,在哪些位置以及我们环境的哪些状态下找到它们,可以为我们节省大量时间和挫败感。 With image analysis we will also have the answers for questions like this one in Stack Overflow.
通过图像分析,我们还将在 Stack Overflow 中找到类似问题的答案。
The process of image selection and analysis is one of the key features of Brobot , an open-source automation framework for Java that wraps SikuliX functions.图像选择和分析的过程是Brobot的关键特性之一,它是一个封装了 SikuliX 功能的 Java 开源自动化框架。 The Brobot documentation has a tutorial on how to build the backbone of your automation, with links to a video series that discusses image selection and preliminary image analysis .
Brobot 文档有一个关于如何构建自动化主干的教程,其中包含讨论图像选择和初步图像分析的视频系列的链接。
Disclaimer : I'm the developer of Brobot.免责声明:我是 Brobot 的开发者。 It's free and open source.
它是免费和开源的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.