I use Primefaces, here is the remote command to trigger the download process
<p:remoteCommand name="cmdGenerateDocument" actionListener="#{logic.onGenerateDocument}" update="xrflDocumentCreationPanel" oncomplete="clickDownloadButton();"/>
The following is my test case:
@Test
public void shouldUpdateStep6ToWarningIfStep1IsValidAfterFinished(){
MainPage mainPage = new MainPage();
waitForLoading(mainPage.getDriver());
EmployeeDetailPage empDetailPage = new EmployeeDetailPage();
waitForLoading(empDetailPage.getDriver());
empDetailPage.fillDataForAllFields();
mainPage.clickNext();
waitForLoading(mainPage.getDriver());
mainPage.clickNext();//move to step 3
waitForLoading(mainPage.getDriver());
mainPage.clickNext();//move to step 4
waitForLoading(mainPage.getDriver());
mainPage.clickNext();//move to step 5
waitForLoading(mainPage.getDriver());
//avoid issue with download automatically on IE8
mainPage.ignoreDownloadProcess();
mainPage.clickNext();//move to step 6
waitForLoading(mainPage.getDriver());
mainPage.jumpToEmployeeDetailTab();
waitForLoading(mainPage.getDriver());
empDetailPage.setEmptySalutaion();
waitForLoading(mainPage.getDriver());
mainPage.jumpToDocumentCreationTab();
waitForLoading(mainPage.getDriver());
assertTrue(mainPage.isRequriedFinishedAllStepsMessageShown());
assertTrue(mainPage.isRequriedMessageShownOnStep1());
assertTrue(mainPage.isStep6Warning());
}
The content of function "ingnoreDowloadProcess()"
public void ignoreDownloadProcess() {
String script = "clickDownloadButton = function(){};";
((JavascriptExecutor) getDriver()).executeScript(script);
}