How to close download bar

Hi All,

I am using chrome browser to test my web application. In my test case xml file is downloaded and file appears in download bar once the download is complete. Is there any way to close that download bar?

I don’t think so, not from WebUI at least because that is a browser element, not a web element. Perhaps it would be possible to target it from the Windows Desktop APIs but I have not heard of anyone mixing the two API sets or if it’s even possible.

You might try using the Robot class.

Maybe @Brandon_Hein knows a trick?

The short answer is no, you cannot directly close this bar, as it’s a browser element. You could possibly do it using keyboard shortcuts though:

WebElement element = DriverFactory.getWebDriver().findElement(By.xpath("//body"));
element.sendKeys(Keys.chord(Keys.CONTROL, "j")); // opens the download page in a new tab
element.sendKeys(Keys.chord(Keys.CONTROL, "w")); // closes the new tab, and the download bar

You can test this manually. While a download bar is present, press ctrl + j, then ctrl + w on your keyboard. Again this is just a hack, so not sure if it will actually work…

I have already tried that. Control+ J does not work however Control+w works for me. It just close current tab.

The only other tip I can give is that there are some chrome plugins that will hide the bar for you, but you’d have to figure out how to install these plugins programmatically in the code.