我正在使用以下内容尝试将屏幕截图与已保存的.png图像进行比较,但它无效。截图和.png文件是相同的,但我在eclipse中收到以下错误:
java.lang.AssertionError: The following asserts failed:
expected [P(C:/Users/pauljos/tmpDirectory.png) S: 0.7] but found [org.sikuli.script.ScreenImage@58fdd99]
我在eclipse中使用Sikuli,这是我的脚本:
Screen screen = new Screen();
Pattern pattern4 = new Pattern("C:\\Users\\pauljos\\tmpDirectory.png");
screen.click("C:\\Users\\pauljos\\explorerIcon.PNG");
screen.click("C:\\Users\\pauljos\\explorerWhiteSpace.PNG");
screen.type("c:/tmp");
screen.type(Key.ENTER);
ScreenImage img = screen.capture();
sikuli_assert.assertEquals(img, pattern4);
答案 0 :(得分:0)
实际上,您正试图断言不兼容的数据类型Pattern& ScreenImage。你应该像下面这样。
屏幕=新屏幕(); BufferedImage img1 = ImageIO.read(新文件(“C:\ Users \ pauljos \ tmpDirectory.png”));
BufferedImage img = screen.capture()。getImage();
如果(img1.equals(IMG)){
//两张图片相同 }