1

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!!

Eugene S
  • 6,709
  • 8
  • 57
  • 91
Suresh Sharma
  • 186
  • 1
  • 5
  • 23
  • Just to clarify.. The machine where you run your Sikuli tests is an actual (not headless) machine that is one and has a screen? The other thing is to follow the hint in the output and ensure you launch the process with admin permissions. – Eugene S Oct 07 '16 at 05:35
  • I am running Jenkins as windows' service, so it doesn't open the real browser as selenium does. is there any issue with my Jenkins?? – Suresh Sharma Oct 07 '16 at 06:06
  • Did you ever get this issue resolved? I am having a similar issue where Jenkins cannot find the image on the screen but I can run it fine both through command line and Eclipse. –  Nov 08 '19 at 19:56

0 Answers0