-1

I am trying to automate some testing on a 3rd-party site using selenium rc and facing an issue with file chooser. Going down the issue i found that it was a browser native file chooser issue. I was able to handle that but now the problem is that when I click upload button manually file explorer window opens up and when i try to do that through selenium test case it does not open even if selenium is clicking that button

Another issue is selenium only clicks and is able to find that button if i move my mouse over that button. Here is the related code snippet:

public void testBox() throws Exception {
    selenium.setTimeout("10000000000");
    selenium.open("/files");
    selenium.click("id=login_button_credentials");
    selenium.waitForPageToLoad("150000");

    while(!selenium.isElementPresent("id=upload_split_arrow"))
    {
            Thread.sleep(10);
    }
    selenium.click("id=upload_split_arrow");
    while(!selenium.isElementPresent("id=upload_file1"))
    {
            Thread.sleep(10);
    }


    selenium.click("id=upload_file1");
    Thread.sleep(10000000);
    }

Can anyone suggest me some workaround for that?

auny
  • 1,920
  • 4
  • 20
  • 37

2 Answers2

1

Don't click on upload file button, you just directly type the file path like below.

 selenium.type("id=upload_split_arrow","/home/test/Desktop/YourFile.txt");
 selenium.click("id=upload_file1");

I hope this will work for you.

Santoshsarma
  • 5,627
  • 1
  • 24
  • 39
  • that helped. But the 2nd problem is still there.Selenium is unable to find that button until i move that mouse over that button – auny Dec 08 '12 at 19:00
  • use mouseover method to place the mouse over that element, and then do your operation. – Santoshsarma Dec 11 '12 at 06:00
  • mouseover method doesnot seem to work. Since mouseover tries to find the element. But it is unable to find the element until i take the mouse over to that element – auny Dec 11 '12 at 06:04
  • Instead of specifying that particular element, just try with parent of the element and which is visible. In the above case place the mouse over the tag and try. – Santoshsarma Dec 11 '12 at 06:08
0

If the element is of type file, you can try using attachFile function.

niharika_neo
  • 8,441
  • 1
  • 19
  • 31