【问题标题】:"Image not valid, but TextSearch is switched off!" error - Sikuli on Mac“图像无效,但 TextSearch 已关闭!”错误 - Mac 上的 Sikuli
【发布时间】:2018-01-19 13:50:45
【问题描述】:

我正在尝试使用 Sikuli 和 Eclipse 在 Mac 上自动化桌面应用程序。

源代码:

import org.sikuli.script.FindFailed;
import org.sikuli.script.ImagePath;
import org.sikuli.script.Screen;

public class TextEditorExample {

public static void main(String[] args) throws FindFailed {
 // TODO Auto-generated method stub
Screen s=new Screen();
System.out.println(ImagePath.getBundlePath());
 s.click("spotlight_icon.png");
 s.find("spotlight.png");
 s.type("spotlight.png","finder");
 s.click("applications.png");
 s.click("texteditor_icon.png");
 s.find("texteditor.png");
 s.type("texteditor.png","Sikuli Example");

 }
}

但我收到以下错误:

[error] Image: Image not valid, but TextSearch is switched off!
[error] RunTimeAPI: Wait: Abort: unknown
[error] RunTimeAPI: ImageMissing: spotlight_icon.png

sikuli脚本路径:

  /Users/adamin/Desktop/Automation/SikuliExample/src/TextEditorExample.java

图像路径:

/Users/adamin/Desktop/Automation/SikuliExample/src/spotlight_icon.png
/Users/adamin/Desktop/Automation/SikuliExample/src/spotlight.png
/Users/adamin/Desktop/Automation/SikuliExample/src/applications.png
/Users/adamin/Desktop/Automation/SikuliExample/src/texteditor_icon.png
/Users/adamin/Desktop/Automation/SikuliExample/src/texteditor.png

谁能帮我解决这个问题?

【问题讨论】:

    标签: java eclipse macos automation sikuli


    【解决方案1】:

    图像路径默认设置为您的项目根文件夹,并且只会在那里查找模式。只需手动将捆绑路径设置为您的文件所在的位置:

    ImagePath.setBundlePath("fullpath");
    

    或者,将您的文件放在以下文件夹返回的任何文件夹中:

    System.out.println(ImagePath.getBundlePath());
    

    【讨论】:

      【解决方案2】:

      使用模式。

      Pattern pattern = new Pattern(path+"spotlight_icon.png");
      Screen s=new Screen();
              try {
                  s.click(pattern);
              } catch (FindFailed e) {
                  e.printStackTrace();
              }
      

      【讨论】:

        【解决方案3】:

        这个错误很可能是图片无法加载时出现的,同时,使用这种方法

        try{
            String path = "path of your image";
            Pattern target = new Pattern(path);
            Screen scr = new Screen();
            scr.click(target);
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        

        是的

        【讨论】:

          猜你喜欢
          • 2017-02-21
          • 2013-06-08
          • 1970-01-01
          • 2021-12-23
          • 1970-01-01
          • 2015-10-06
          • 1970-01-01
          • 1970-01-01
          • 2013-12-05
          相关资源
          最近更新 更多