How can I prevent a new window from opening when clicking a link?
I am writing Selenium tests to check file download functionality in our web app. I get some files listed in a grid, I select several and proceed with a download link for a zip (compressed folder). When I click the link, a new window opens and I see the download dialog. I was able to bypass the download dialog by setting some profile preferences in my test...
prof.SetPreference("browser.download.folderList", 2); // This needed to enable alternate download folder setting. prof.SetPreference("browser.download.dir", "C:\\SeleniumTestData\\Download"); prof.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-zip-compressed"); prof.SetPreference("browser.helperApps.alwaysAsk.force", false);
With the above I no longer see the download dialog and after clicking the link I see the message that download completed and the file is in the intended location. However, a new window was still opened.
I've tried setting some of the open new window settings I found in about:config, but nothing seemed to help.
When I run my test steps manually the new window does not open and the file is downloaded.
I'm not really sure what the difference could be running the test steps manually vs via the Selenium test, but the behavior is definitely different.
The one thing I did notice is that running manually doesn't show the completion dialog. I just see the quick progress flash in the top toolbar. When I run the test via Selenium, I do see the completion message.
Any help in preventing the additional window from opening during my coded test would be greatly appreciated!
Thanks!!
All Replies (2)
You need to do a parent window true call.
I'm a newb so I'm not really sure what that means. Is that a profile preference setting I could add or different code?
I'm not sure if I was clear above, but in the manual run of steps, the download is taken care of in original/same window/tab. There is no additional tab used in that scenario either.