Selenium - Override javascript functions to ignore downloading process - The Koch Family
The Koch Family The Koch Family

Latest news

جاري التحميل ...

Selenium - Override javascript functions to ignore downloading process

I have got an issue with downloading process on IE 8. This browser blocks my automatic-download functionality on my app so that I could not work with my test case any more after that. In my case, I didn't care about the file is downloaded or not, I just focus on the result after downloading process finished successfully. Therefore, I found a solution to ignore this process so that I can work normally.

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);
}

Comments



If you like the content of our blog, we hope to stay in constant communication, just enter your email to subscribe to the blog's express mail to receive new blog updates, and you can send a message by clicking on the button next ...

إتصل بنا

About the site

author The Koch Family <<  Welcome! I'm so glad that you stopped by Your Modern Family blog. Together, we will talk about raising kids, organizing the home and saving money! and Tips & tricks and more…

< Learn more ←

Blog stats

Sparkline 2513183

All Copyrights Reserved

The Koch Family

2020