0

We use a Jenkins-Slave to execute Selenium Gui test. The slave is started using WebStart and runs on a Windows 7 machine. The test contains the downloading of PDF files that should be checked for existence as well as correctness by looking up texts in it. The problem is, the running Selenium tests do not see the files downloaded by firefox. In fact the process doesn't seem to see any file in the directory.

The test runs just fine if I execute it on my local machine, straight from the IDE rather than using Jenkins or WebStart at all.

I already considered the following:

  • Am I checking the wrong directory? No, I copied the file.getAbsolutePath() to the windows explorer and can see the files. I'm also pretty sure I'm on the right machine.
  • Is it a timing issue? E.g. is the file not finished downloading? No, I use WebDriverWait and wait for 30 seconds to find the file, while it takes actually round abound 1 sec to create and download the PDF:

    WebDriverWait wait = new WebDriverWait(driver, 30, 1000);
       wait.until(new Predicate<WebDriver>(){
         public boolean apply(WebDriver driver){
           try{
             log.info("file: " + pdfFile.getAbsolutePath() + ", exists: " + pdfFile.exists() + ", size: " + pdfFile.length());
             // test files content ...
           }
           catch (IOException e){
             return false;
           }
         }
       });
    

Has anybody any idea what could be wrong? Wild guesses are welcome...

UPDATE I checked the jenkins.jnlp file and it contains "all-permissons" so it should be able to access the file system.

<security>
   <all-permissions/>
</security>

UPDATE 2 To make that clear: I run Selenium tests using Jenkins. Selenium remote controls Firefox and while doing so, PDF files are downloaded. The problem is, the Java process, e.g. my test classes can't find the files.

Tim Büthe
  • 62,884
  • 17
  • 92
  • 129
  • **I take it, the [sandbox](http://docs.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/security.html) settings of WebStart allow downloading.** If so: Was the logged pdfFile path correct? Was exists always false? What about pdfFile.canRead()? (Normally my guess would be the system property `user.dir` which differs in IDE and standalone.) – Joop Eggen Jun 25 '12 at 10:15
  • I think that isn't the problem. Jenkins Slaves contain all permissions (updated my question to make that clear), and I think I would get an Exception if the dir couldn't be access because of missing permissions. Also the user.dir is a fair guess, however, when I log the file.getAbsolutePath it should be the right one. No matter if it differs on both machines. – Tim Büthe Jun 25 '12 at 11:59
  • Are you using [PersistenceService](http://docs.oracle.com/javase/7/docs/jre/api/javaws/jnlp/javax/jnlp/PersistenceService.html); see [here for an example](http://docs.oracle.com/javase/1.4.2/docs/guide/jws/developersguide/examples.html#PersistenceService)? Using a FileContents i.o. File. Jar signing I would do too. – Joop Eggen Jun 25 '12 at 20:53
  • I think you got that wrong @JoopEggen. I don't use the WebStart application to store the files. WebStart is used to start a Jenkins-Slave. This slave executes a Selenium test, and that test drives Firefox and thereby PDF files are generated and downloaded using Firefox. I updated my question to make that clear. – Tim Büthe Jun 26 '12 at 22:12

2 Answers2

0

How are you running Jenkins on Windows 7? Did you install it as a service? Have you checked this list of common problems? https://wiki.jenkins-ci.org/display/JENKINS/My+software+builds+on+my+computer+but+not+on+Jenkins

sti
  • 11,047
  • 1
  • 27
  • 27
  • Thanks, the list seems to be quite helpful. However, we don't have installed it as a windows service but started it using WebStart. – Tim Büthe Jun 26 '12 at 22:14
0

Changing my relative path:

new File("downloads/");

to an absolute by calling "getAbsoluteFile" or just use "C:...":

new File("downloads/").getAbsoluteFile();

fixes the problem (but I don't understand why). This is, because Jenkins sets the user.id and because of bugs in the java.io.File implementation this can cause problems. See this other SO question and this Java bug report.

Community
  • 1
  • 1
Tim Büthe
  • 62,884
  • 17
  • 92
  • 129