Skip to content

Chapter9 File Download examples assume that the Project's directory is equal to System.getProperty("user.dir"), but sometimes this is not the case #21

@kazurayam

Description

@kazurayam

In the kazurayam21 branch, the sample code of the Chapter9 "File Download" section explains several approaches where to locate the output files from the test cases.

based on the User's home directory

https://github.com/kazurayam/selenium-webdriver-java/blob/kazurayam21/selenium-webdriver-junit4/src/test/java/io/github/bonigarcia/webdriver/junit4/ch09/download/DownloadChromeJUnit4Test.java

        targetFolder = new File(System.getProperty("user.home"), "Downloads");

based on the Current Working Directory

https://github.com/kazurayam/selenium-webdriver-java/blob/kazurayam21/selenium-webdriver-junit4/src/test/java/io/github/bonigarcia/webdriver/junit4/ch09/download/DownloadFirefoxJUnit4Test.java

        targetFolder = new File(".");

and

https://github.com/kazurayam/selenium-webdriver-java/blob/kazurayam21/selenium-webdriver-junit4/src/test/java/io/github/bonigarcia/webdriver/junit4/ch09/download/DownloadHttpClientJUnit4Test.java

...
        File pngFile = new File(".", "webdrivermanager.png");
...
        File pdfFile = new File(".", "webdrivermanager.pdf");
...

The new File(".") means the Current Working Directory, which is equal to System.getProperty("user.dir"). The document wrotes:

We use the local project folder.

However, this is not necessarily right. As I explained in the #8, The Current Working Directory is NOT necessarily equal to the local project folder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions