I am using Sikuli script for downloading a file on Windows system in Selenium script with Maven framework. It's working fine when I run my tests via rightclick on testng.xml
and runas TestNG Suite, but when I tried to run same via Jenkins it doesn't work properly not it failed test case.
Here is my Selenium Webdriver code:
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 code:
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");
}
}
and Jenkins error is:
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
and it's not storing file in mentioned directory. Moreover I maximize browser to:
driver.manage().window().setSize(new Dimension(1366, 768));
pls suggest!!