Prabu
Prabu

Reputation: 3728

How to Handle Browser Popup (During the Download) using Java

currently we scrap the data from Websites using Web driver (Selenium)with Java, during that Scrapping we need to do some download process (i.e XML file Download), let me know how will handle the Browser Popup (save As Dialog) using Java

<a href="javascript:downloadXML()">
    <img width="40" height="20" border="0" name="imag34" alt="Download" src="/pair/img/tabs/downloadxml.gif">
</a>

We are using the following code to click the above image

driver.findElement(By.xpath("(//img[@alt='Download'])[3]")).click();

After clicking that image, it will open a "Save as.." popup. How do we go to that popup and do testing on that?

enter image description here

Upvotes: 2

Views: 10540

Answers (3)

srinivas
srinivas

Reputation: 1

This is actually a windows pop up and firebug will not able to detect this.If you are using windows OS then you can use AutoIT tool this will solve your problem.

Upvotes: 0

user3328505
user3328505

Reputation: 11

I've just solved this problem using the Robot class from Java. The Robot class allow you to simulate keybord press, in so doing you can work with TABs and Enters in order to execute the download.

Upvotes: 0

TechSpellBound
TechSpellBound

Reputation: 2555

This download popup is basically a window.open Javascript call with the URL of the XML file. So this seems to be the relevant link :

How to switch to the new browser window, which opens after click on the button?

Upvotes: 0

Related Questions