2017-08-11 73 views
1

我试图在Mac上使用Sikuli和Eclipse自动化桌面应用程序。“图片无效,但TextSearch已关闭!”错误 - Mac上的Sikuli

的源代码:

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"); 

} 
} 

但我发现了以下错误:图像的

/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 
Sikuli脚本的

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

路径

任何人都可以帮助我解决这个问题吗?

回答

1

图像路径默认设置为您的项目根文件夹,并且只会在那里查找图案。只需手动设置束路径无论你的文件有:

ImagePath.setBundlePath("fullpath"); 

或者,将您的文件夹无论是通过返回:

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

利用格局。

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

此错误最有可能来的时候像不可载入,同时,使用这种方法

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

ÿ

相关问题