What you are seeing is NOT a Javascript triggered alert, but is an OS dialog box which cannot be handled by WebDriver. That explains why you see the size as 1 when you query the window handles.
You might want to spend sometime reading through this blog post : http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/e55df771-19ed-4b59-a5f2-d76afacfafda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.