2

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

Prabu
  • 3,550
  • 9
  • 44
  • 85

3 Answers3

0

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?

Community
  • 1
  • 1
TechSpellBound
  • 2,505
  • 6
  • 25
  • 36
  • first point - while clicking the "Download XML" Button not getting the URL, and second Point - that save popup was not a Parent and Child window,not able to find / trigger the element in that save popup, also i was tried with your option its seems not working – Prabu Jan 27 '14 at 10:04
  • Try using Firebug tool in Firefox to find out what kind of WebElement this popup is. – TechSpellBound Jan 27 '14 at 10:06
  • this is for Browser popup, unable to inspect the element with firebug or developer tools – Prabu Jan 27 '14 at 10:12
  • Check if any of this helps: http://opensource-soa.blogspot.in/2009/10/how-to-capture-pop-up-window-using.html – TechSpellBound Jan 27 '14 at 10:24
0

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.

user3328505
  • 11
  • 1
  • 2
0

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.

srinivas
  • 1
  • 2