我正在使用Sikuli脚本在Selenium脚本中使用Maven框架在Windows系统上下载文件。当我通过右键单击testng.xml
和runas TestNG Suite运行我的测试时,它工作正常,但是当我尝试通过Jenkins运行它时,它无法正常运行而不是测试用例失败。
这是我的Selenium Webdriver代码:
if (prop.getProperty("browser").equalsIgnoreCase("firefox")) {
/*ProfilesIni profile=new ProfilesIni();
FirefoxProfile myprofile=profile.getProfile(prop.getProperty("firefoxprofilename"));*/
FirefoxProfile myprofile=new FirefoxProfile();
myprofile.setPreference("browser.download.dir",prop.getProperty("firefoxfilesave"));
myprofile.setPreference("browser.download.folderList", 2);
myprofile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/zip");
driver=new FirefoxDriver(myprofile);
Sikuli代码:
if (prop.getProperty("browser").equalsIgnoreCase("firefox")){
/* Runtime.getRuntime().exec("D:\\autoIT\\save.exe");
Thread.sleep(600000);
System.out.println("done");*/
try {
src=new Screen();
prn=new Pattern(System.getProperty("user.dir")+prop.getProperty("saveradio"));
Thread.sleep(3000);
src.click(prn);
prn=new Pattern(System.getProperty("user.dir")+prop.getProperty("saveOK"));
src.click(prn);
System.out.println(name.getName()+" Report gets downloaded successfully");
} catch (Exception e) {
}
try {
src=new Screen();
Pattern img1=new Pattern(System.getProperty("user.dir")+prop.getProperty("saveimage"));
Thread.sleep(3000);
src.click(img1);
System.out.println(name.getName()+" Report gets downloaded successfully");
} catch (Exception e) {
}
}else {
System.out.println("Browser is chrome so file save automatically");
System.out.println(name.getName()+" Report gets downloaded successfully");
}
}
和詹金斯的错误是:
INFO: Registering type java.lang.Number
[error] Location: outside any screen (28432416, 0) - subsequent actions might not work as expected
[error] Location: outside any screen (28432640, 0) - subsequent actions might not work as expected
[error] Location: outside any screen (28432640, 0) - subsequent actions might not work as expected
[error] Location: outside any screen (28432256, 0) - subsequent actions might not work as expected
[error] RobotDesktop: checkMousePosition: should be L(28432640,0)
but after move is L(28432256,0)
Possible cause in case you did not touch the mouse while script was running:
Mouse actions are blocked generally or by the frontmost application.
You might try to run the SikuliX stuff as admin.
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 106.146 sec - in TestSuite
并且它没有在提到的目录中存储文件。此外,我最大化浏览器:
driver.manage().window().setSize(new Dimension(1366, 768));
建议!!