http://qs321.pair.com?node_id=1048314

ragilla has asked for the wisdom of the Perl Monks concerning the following question:

Hi , i am using Selenium::Remote::Driver; module to download some files from webpage, Actually when i click the link in the webpage i will get an zip file , as i cannot save it directly, i am using get_page_source function to get that page and printing (putting ) in file and after that download i am renaming that file to .zip file , but when i open the file i am getting error that file is damaged , so how i can download the file without damging , please help me , i have attached code below please help me how to solve the issue

use Selenium::Remote::Driver; @webelements=$driver->find_elements("input","tag_name"); foreach $elemnt (@webelements){ sleep(5); $string = $elemnt->get_attribute('src'); print "The string is [$string] \n"; if ( $string && $string =~ /disk25.gif/i){ print "one lement found \n"; $elemnt->submit(); sleep(5); #$elemnt->click(); my @handles = $driver->get_window_handles; print "handles in last loop @handles ".@handles; open (F1,'>C:\Users\u0156151\Desktop\final'); open (FS,'>C:\Users\u0156151\Desktop\finalfile'); #$F="Z$count"; binmode FS; print FS $driver->get_page_source(); print F1 $driver->get_page_source(); last; $count++; } }

so after running the above code i will get two files final and finalfile , when i rename them to final.zip and finalfile.zip the zip file is getting corrupted