'Stop the selenium server until File uploaded

I am using a file upload task with Selenium.

The problem here is, to upload file, it is taking 5-10 seconds time. But i have to stop the Selenium server until it uploaded completely.

Here is some example code.

selenium.type("id=Fileuploader","c:\\mypic.jpg");
selenium.click("id=submmit");

It is giving error because the selenium.click statement is executing right after the selenium.type statement without waiting for the file to upload fully.

So, what should I use here to stop the Selenium server (server has to wait for sometime)?



Solution 1:[1]

If worst, you can always use some Thread.sleep() in the code. But the best way is to see the advanced usage - explicit and implicit waiting

Solution 2:[2]

After uploading the file, new element is coming which showing the preview of the uploaded element.

So, i used

selenium.isVisible("xpath of new preview element") 

Put it in loop. It will work.

Thank you.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ayush Choudhary
Solution 2 Ranadheer Reddy