2017-08-22 42 views
0

我是sikuli和硒的新手。当执行以下赛前我得到“FindFailed:镜像文件空磁盘上找不到”Selenium sikuli 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);  
} 
+0

它在哪里出错?你可以发布stackstrace吗? –

回答

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