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


In reply to Selenium get_page_source function by ragilla

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.