错误[错误]图片:无法加载:file:/ C:/Users/gskumar/Desktop/images/main.png

时间:2017-02-09 07:21:58

标签: java sikuli

import java.awt.Robot;

import org.sikuli.script.Screen;
import org.testng.annotations.Test;

public class Test1
{

    static final int ACCEPTABLE_DELAY_LONG  = 5000 ;
    static final int ACCEPTABLE_DELAY_SHORT = 3000;
    Robot r;
    Screen event;
    RobotEvents re; 
    @Test(priority=1)
    public void Open() throws Exception
    {
        re=new RobotEvents();
        r=new Robot();
        event=new Screen();
        Runtime.getRuntime().exec("C:\\Program Files (x86)\\SAP\\FrontEnd\\SAPgui\\saplogon.exe");

        Thread.sleep(ACCEPTABLE_DELAY_SHORT);

        event.type("./images/main.png","personal");
        //event.type("images\\main.png","personal");
        //event.type("D:\\Project1\\Server\\images\\main.png","personal");
        Thread.sleep(ACCEPTABLE_DELAY_SHORT);

    }

}

1 个答案:

答案 0 :(得分:0)

正如我所看到的,错误消息告诉您它无法在文件系统上找到图像。您可以尝试使用以下命令更改映像的路径目录:

 ImagePath.add(TestSikuli.class.getCanonicalName() + "/images");

然后,你必须改变

event.type("./images/main.png","personal");

有:

event.type("/main.png","personal");