Real World Example

KYC Upload and Statement Download

Banking, fintech (Paytm, Zerodha-style) and insurance portals have two common flows: upload KYC documents, and download statements or policy PDFs. A regression test covers both and keeps evidence screenshots for the audit team:

driver.findElement(By.id("pan-upload")).sendKeys(Path.of("src/test/resources/kyc/pan-sample.png").toAbsolutePath().toString());
driver.findElement(By.id("submit-kyc")).click();
WebElement status = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("kyc-status")));
Files.copy(status.getScreenshotAs(OutputType.FILE).toPath(), Path.of("target/evidence/kyc-status.png"),
        StandardCopyOption.REPLACE_EXISTING);

driver.findElement(By.linkText("Download statement (Sep 2026)")).click();
Path pdf = downloads.resolve("statement-2026-09.pdf");
wait.until(d -> Files.exists(pdf));
System.out.println(status.getText() + " | statement " + Files.size(pdf) / 1024 + " KB");

Example

Output:

Run KycAndStatementTest.main()

Example output

KYC submitted - under review | statement 86 KB

Takeaway

Upload = sendKeys with a path. Download = a fixed folder plus a wait for the file. Screenshots = evidence. Keep sample files in src/test/resources so every machine has them.