0

I am new to the selenium RC. I have been working in eclipse to run a simple junit test case to run and download flashplayer from adobe.com.

But the selenium RC is not able to click or even recognise the downloads pop up window. I have been seeing several suggestions in google search but still I am not able to do it.

I have been trying to get the window ID or name of the pop up window to work with it, but still I am not able to do it. I have copied the major function of my code here down below:

public void testPopup() throws Exception 
    {
    selenium.open("http://get.adobe.com/");
    selenium.open("/flashplayer/");
    selenium.click("id=buttonDownload");

    String ids[]=selenium.getAllWindowIds();
    for(int i=0;i<ids.length;i++)
        System.out.println(ids[i]);
    String[] windownames=selenium.getAllWindowNames();
    for(int i=0;i<windownames.length;i++)
        System.out.println(windownames[i]);

        String feedWinId = selenium.getEval("{var windowId; for(var x in selenium.browserbot.openedWindows ) {windowId=x;} }");
    System.out.println(feedWinId);
        selenium.chooseOkOnNextConfirmation();
    selenium.waitForPageToLoad("30000");                                        
}

It will be great if someone can help me out with this.

Thanks

Petr Janeček
  • 37,768
  • 12
  • 121
  • 145
user1489969
  • 11
  • 3
  • 6

2 Answers2

0

The short answer: you can't.

The longer, but still disappointing answer:

You can't, because no current Selenium implementation supports it. The Selenium people know about it, it's actually nr. 13 in most wanted features in Selenium right now

Selenium RC will never have it because of its technical limitations (It's pure JavaScript. And pure JavaScript can't download and save files.) and it has been deprecated over a year ago. Selenium WebDriver ... well, maybe, in the future. The various things you can try instead:

  • Rethink whether you really need to download the file. Isn't is ok just to assert that the file exists and can be downloaded by making a HTTP request and seeing that the answer was 200 OK?
  • Can't you download the file using pure Java after you get it's URL via Selenium? I personally think this is the best way to go.
  • If you're using WebDriver, there is a great tool for downloading files!
  • If you're using Firefox, you can set up a clean testing profile that will be configured so that it will download every clicked file into some specified folder. There are addons out there that can help you with it, too. I'm not sure whether Selenium RC supports usign a precreated profile, but Selenium WebDriver definitely does.
  • If you're using one given browser to do your tests, you can figure out how to download a file "blindly" by pressing buttons blindly. The Robot class can help you with that. You just click the file and then blindly press Enter or whatever keys to download your file into the right place. There is also AutoIt framework which a lot people use for this task.
Community
  • 1
  • 1
Petr Janeček
  • 37,768
  • 12
  • 121
  • 145
0

You can not automate system generate pop-up by using selenium.
For that you have shift over Autoit with selenium.
With the help of this you can records your activities on download pop-up

Rohit Ware
  • 1,982
  • 1
  • 13
  • 29
  • Hi ROhit, thanks for the reply. But I am looking for a solution in which I can run the selenium scripts from linux. It seems like AutoIT can be run using Wine. But can you tell me if there is any other way I can run this selenium script in linux? – user1489969 Jul 03 '12 at 17:08