Upload multiple pdf issue on jenkins with java selenium

23 views Asked by At

I've got some issues with uploading pdf on jenkins.

I run a java/selenium course, and there are 2 pdfs to upload.

Localy with my ide, everything is fine : i've get the 2 pdf in a downloads folder.

But with jenkins, I get the downloads folder with only the first pdf.

I've tried to upload only the second one, and it works.

I get the downloads folder with the second pdf.

So it seems for some unclear reason that i can't upload several pdf in a row.

Here 's my java code:

private static void launchChromeDocker() {
        System.setProperty("webdriver.chrome.driver", "/usr/lib/chromium/chromedriver");
        final ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.addArguments(
                "lang=fr-FR",
                "--no-sandbox",
                "--disable-dev-shm-usage",
                "--disable-gpu",
                "--disable-web-security",
                "user-data-dir=/profile_pushbullet",
                "load-extension=/profile_pushbullet/Default/Extensions/chlffgpmiacpedhhbkiomidkjlcfhogd/364_0",
                "--remote-allow-origins=*",
                "--ignore-certificate-errors"
        );

        final Map<String, Object> chromePrefs = new HashMap<>();
        chromePrefs.put("profile.exit_type", "Normal");        

            final String parentDirectoryPath = System.getProperty("user.dir");
            final String downloadFilepath = parentDirectoryPath + "/downloads/";
            logger.info("Chrome Download path set to: " + downloadFilepath);
            final File downloadFolder = new File(downloadFilepath);
            if (!downloadFolder.exists()) {
                downloadFolder.mkdir();
            }

        chromePrefs.put("download.default_directory", downloadFilepath);
        chromePrefs.put("download.prompt_for_download", false);       
       
        chromeOptions.setExperimentalOption("prefs", chromePrefs);
        chromeOptions.setAcceptInsecureCerts(true);
        chromeOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);

        final DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
        desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
       
        driver = new ChromeDriver(chromeOptions);
    }

Here's the jenkins artifact configuration :

Monitoring/**/**/*.html, Monitoring/**/**/screenshots/*.png, loan/*.txt, **/**.pdf

Thank for your help

0

There are 0 answers