在磁盘上找不到Selenium sikuli ImageFile null

时间:2017-08-22 13:37:47

标签: selenium sikuli

我是sikuli和selenium的新手。在执行pregame之后,我得到了" FindFailed:在磁盘上找不到ImageFile null"

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;

public class prac1 
{
@Test
public void f() throws Exception 
{
    System.setProperty("webdriver.chrome.driver", "D://rakesh//software//selenium browser//chrome 2.30//chromedriver.exe");
    WebDriver driver = new ChromeDriver();
    driver.manage().window().maximize();
    driver.get("http://www.techved.com/career");
    driver.findElement(By.id("aplybtn1")).click();

    driver.findElement(By.xpath("//html/body")).sendKeys(Keys.PAGE_DOWN);
    Pattern submit_btn = new Pattern(".//ele_screenshot//choose_btn.PNG");
    Pattern file_upload = new Pattern(".\\ele_screenshot\\file_upload.PNG");
    Pattern open_btn = new Pattern(".\\ele_screenshot\\open_btn.PNG");

    Screen screen = new Screen();
    screen.setAutoWaitTimeout(3);
    screen.click(submit_btn);
    screen.type(file_upload, "C:\\Users\\techved\\Desktop\\performance.txt");
    screen.click(file_upload);
    screen.click(open_btn);     
}   

1 个答案:

答案 0 :(得分:0)

看起来您的代码中存在一些问题(例如系统路径不一致),我现在不会讨论,但您应该检查。

该错误几乎意味着它所说的图像不能位于磁盘上。这通常意味着bundlePath到与您的图像文件不同的位置。要了解当前用于搜索图像和设置自定义路径的路径,请使用以下命令:

System.out.println(ImagePath.getBundlePath()); // print current bundlePath
ImagePath.setBundlePath("src/main/resources/images"); // set custom bundlePath

System.out.println(ImagePath.getBundlePath()); // print new bundlePath

您可以找到更多信息here