这是我的密码
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
//Open the URL
driver.get("http://www.toolsqa.com/automation-practice-form/");
//Maximize the window
driver.manage().window().maximize();
//Click on Button which will open file upload window
driver.findElement(By.xpath(".//*[@id='photo']")).click();
// Implementing Sikuli
ScreenRegion s = new DesktopScreenRegion();
Target target = new ImageTarget(new File("D://SELENIUM WORK-PLACE/File_upload//img//Capture.PNG"));
ScreenRegion r = s.wait(target, 20000);
r=s.find(target); // Locate the target on the screen.
//Create a Canvas object of the type DesktopCanvas.
Canvas test = new DesktopCanvas();
test.addBox(r);
test.addLabel(r, "I am present here");
test.display(5);
}
}的实际结果:点击网页元素,就会打开一个文件上传框.什么都没发生。(但如果我关闭盒子并手动重新打开它,它就能正常工作)
预期输出-它应该在我们第一次打开文件上传框时工作。
发布于 2014-11-28 14:42:16
你的密码没问题。修正到:"D://SELENIUM 的路径
然后,尝试使用下面的图像来获取Filename textfield。因为图像的大小越大,Sikuli就有更多的可能无法检测到元素,因为即使是像素的变化也可能妨碍Sikuli识别元素。

https://stackoverflow.com/questions/27188729
复制相似问题