单击Web元素后无法执行Sikuli脚本。(使用Java的Selenium webdriver)
这是我的密码单击Web元素后无法执行Sikuli脚本。(使用Java的Selenium webdriver),java,selenium,sikuli,Java,Selenium,Sikuli,这是我的密码 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 windo
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);
}
}
实际结果:单击Web元素,它会打开一个文件上传框。什么也没发生。但是如果我关闭这个盒子,然后手动重新打开它,它就可以正常工作了
预期输出-它应该在我们第一次打开文件上传框时工作 您的代码很好。修复以下路径:D://SELENIUM WORK-PLACE//File\u upload//img//Capture.PNG 然后,尝试使用下图获取文件名文本字段。因为图像的尺寸越大,Sikuli就越有可能无法检测到元素,因为即使是像素的变化也可能会妨碍Sikuli识别元素
什么是Capture.PNG?我的意思是,它存储哪个图像?它是存储在我的项目文件夹中的图像的名称。