1

我正在使用 Sikuli 脚本在带有 Maven 框架的 Selenium 脚本中下载 Windows 系统上的文件。当我通过右键单击和 runas TestNG Suite 运行我的测试时,它工作正常testng.xml,但是当我尝试通过 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);

西库里代码:

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));

请建议!

4

0 回答 0