24. Automated File Uploads & Download Verifications

File Upload & Download

import java.nio.file.Paths;

page.locator("input[type='file']").setInputFiles(Paths.get("test-data/invoice.pdf"));

Download download = page.waitForDownload(() -> {
page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Export CSV")).click();
});
download.saveAs(Paths.get("downloads/" + download.suggestedFilename()));

Task

  • Implement uploadDocument:
  • 1. Accept Page page, String selector, String filePath.
  • 2. Call page.locator(selector).setInputFiles(Paths.get(filePath)).
πŸ’‘Common doubts
Did you like the problem?
Lesson 24 of 38
Java
Loading code editor…
Next