Use Java's Paths or File classes to get an absolute path that works on any machine.
For Firefox, use these properties in serenity.conf or serenity.properties : properties
: Always use System.getProperty("user.dir") or Serenity's ${user.dir} placeholder to ensure tests run on both local machines and CI/CD servers like Jenkins. how to set upload and download directory java + serenity bdd
import net.serenitybdd.screenplay.actions.Upload; public class MyStepDefinitions { @Cast Actor user; @When("I upload the document") public void uploadDocument() { user.attemptsTo( Upload.theClasspathResource("data/sample_file.txt").to(MyPage.FILE_INPUT_FIELD) ); } } Use code with caution.
firefox.preferences = "browser.download.dir=${user.dir}/target/downloads;browser.download.folderList=2;browser.helperApps.neverAsk.saveToDisk=application/pdf" Use code with caution. Use Java's Paths or File classes to get
: Downloading files in Chrome's headless mode can be temperamental. In newer versions of Selenium/Serenity, you may need to explicitly allow downloads via chrome.capabilities or use a dedicated WebDriver wrapper .
Serenity provides a built-in Upload class for the Screenplay pattern: firefox
To control where files are saved during a test, you must pass specific browser preferences to the underlying WebDriver via Serenity's configuration. Configuration for Chrome (Recommended)