GetStoredFileAction extends AbstractSeleniumAction { @Override protected void execute(SeleniumBrowser browser, TestContext context) { String filePath = browser.getStoredFile(context.replaceDynamicContentInString(fileName)); context.setVariable(SeleniumHeaders.SELENIUM_DOWNLOAD_FILE, filePath); } GetStoredFileAction(Builder builder); String getFileName();  }
@Test public void testExecute() throws Exception { seleniumBrowser.storeFile("classpath:download/file.txt"); GetStoredFileAction action = new GetStoredFileAction.Builder() .browser(seleniumBrowser) .fileName("file.txt") .build(); action.execute(context); Assert.assertNotNull(context.getVariable(SeleniumHeaders.SELENIUM_DOWNLOAD_FILE)); }
@Test(expectedExceptions = CitrusRuntimeException.class, expectedExceptionsMessageRegExp = "Failed to access stored file.*") public void testExecuteError() throws Exception { GetStoredFileAction action = new GetStoredFileAction.Builder() .browser(seleniumBrowser) .fileName("unknown.txt") .build(); action.execute(context); }