简体   繁体   English

为什么Sikuli找不到图片路径

[英]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();
        }

    }

}

查看图像文件的路径。仍然为什么 sikuli 不喜欢它

ImagesAPi.sikuli 的目的是什么?

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: 要检查的几件事是:

  1. The pattern is exactly similar to the area you are trying to find on the screen. 该图案与您试图在屏幕上找到的区域完全相似。
  2. Colors and shades 颜色和阴影
  3. Timing. 定时。 Maybe Sikuli times out before it finds the pattern. 也许Sikuli在找到模式之前就超时了。 That can happen if the screen has been recently changed, like if you just navigated there.\\ 如果最近更改了屏幕(例如您刚刚浏览那里),则会发生这种情况。\\

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.

相关问题 除非使用整个路径,否则Java applet无法使用ImageIcon查找资源映像 - Java applet not able to find resource image with ImageIcon unless entire path is used 无法使用sikuli自动化桌面应用程序 - Not able to automate desktop application using sikuli jQuery Ajax发布方法不成功(无法找到路径): - jQuery Ajax post method not successful (not able to find the path): “图像无效,但 TextSearch 已关闭!” 错误 - Mac 上的 Sikuli - "Image not valid, but TextSearch is switched off!" error - Sikuli on Mac 为什么我第一次使用 sikuli 时会出现此错误? - Why am I getting this error while using sikuli on for the first time? Android为什么无法在构建路径中的项目中找到类? - Why can't Android find class in project on build path? 使用带有 webdriver/sikuli 的 Appium 时出现“原始错误:找不到连接的 Android 设备”错误 - Getting "Original error: Could not find a connected Android device" error when using Appium with webdriver/sikuli UnsatisfiedLinkError:C:\\ Program Files(x86)\\ Sikuli X \\ libs \\ VisionProxy.dll:找不到依赖的库 - UnsatisfiedLinkError: C:\Program Files (x86)\Sikuli X\libs\VisionProxy.dll: Can't find dependent libraries 无法找到 Face 和 FaceRecognition 类 - Not able to find Face and FaceRecognition classes 在Eclipse中运行无法找到该类 - Running in Eclipse is Not Able to Find the Class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM