This is the source html tag <input type="file" name="ctl00$ContentPlaceHolderContent$FileUpload_op +fFile" id="ctl00_ContentPlaceHolderContent_FileUpload_opfFile" style= +"width:406px;" />
use strict; use warnings; use Win32::IEAutomation; my $ie = Win32::IEAutomation->new( visible => 1, maximize => 1, warnings => 1, ); $ie->gotoURL('http://www.example.com'); $ie->getTextBox('name:', 'ctl00$ContentPlaceHolderContent$FileUpload_o +pfFile')-> SetValue('C:\test\9780547076034NIMAS.opf'); $ie->WaitForDone(); $ie->closeIE();
There is no change to the textbox were we upload a file any help on this... I used all the possibilities like
$ie->getTextBox('name:', 'ctl00$ContentPlaceHolderContent$FileUpload_o +pfFile')->SetValue('C:\test\9780547076034NIMAS.opf'); $ie->getTextBox('name:', 'ctl00$ContentPlaceHolderContent$FileUpload_o +pfFile')->SetValue('C:/test/9780547076034NIMAS.opf'); $ie->getTextBox('name:', 'ctl00$ContentPlaceHolderContent$FileUpload_o +pfFile')->SetValue('C:\\test\\9780547076034NIMAS.opf'); $ie->getTextBox('name:', 'ctl00$ContentPlaceHolderContent$FileUpload_o +pfFile')->SetValue('C://test//9780547076034NIMAS.opf'); $ie->getTextBox('name:', 'ctl00$ContentPlaceHolderContent$FileUpload_o +pfFile')->SetValue("C:\test\9780547076034NIMAS.opf"); $ie->getTextBox('name:', 'ctl00$ContentPlaceHolderContent$FileUpload_o +pfFile')->SetValue("C:/test/9780547076034NIMAS.opf"); $ie->getTextBox('name:', 'ctl00$ContentPlaceHolderContent$FileUpload_o +pfFile')->SetValue("C:\\test\\9780547076034NIMAS.opf"); $ie->getTextBox('name:', 'ctl00$ContentPlaceHolderContent$FileUpload_o +pfFile')->SetValue("C://test//9780547076034NIMAS.opf");

Here is the html source file

<table cellpadding="1" cellspacing="1" border="0"> <tr> <td colspan="3"> <table cellpadding="1" cellspacing="1" style="width: 5 +00px; margin-left: 60px;"> <tr> <td colspan="3"> </td> </tr> <tr> <td class="label" colspan="3"> <label for='ctl00_ContentPlaceHolderConten +t_FileUpload_opfFile'><b>OPF file to auto-populate the metadata:</b>< +br /></label> <input type="file" name="ctl00$ContentPlac +eHolderContent$FileUpload_opfFile" id="ctl00_ContentPlaceHolderConten +t_FileUpload_opfFile" style="width:406px;" /></td> </tr> <tr> <td colspan="3"> &nbsp;<br /> <input type="submit" name="ctl00$ContentPl +aceHolderContent$btnPullMetadata" value="Validate &amp; Populate Fiel +ds Below" onclick="javascript:WebForm_DoPostBackWithOptions(new WebFo +rm_PostBackOptions(&quot;ctl00$ContentPlaceHolderContent$btnPullMetad +ata&quot;, &quot;&quot;, true, &quot;vgOPFValidation&quot;, &quot;&qu +ot;, false, false))" id="ctl00_ContentPlaceHolderContent_btnPullMetad +ata" title="Validate your OPF and pulling data out through OPF metada +ta" class="defaultButton" style="width:350px;" /><br />

Update: Dear monks i wrote a simple html file this is the file

<html> <head> </head> <body> File to upload: <INPUT TYPE=TEXT NAME="upfile"><BR> <INPUT TYPE=SUBMIT VALUE="Submit"> </body> </html>

This is my perl code

use strict; use Win32::IEAutomation; use warnings; my $ie = Win32::IEAutomation->new( visible => 1, maximize => 1); $ie->gotoURL('C:\ex.html'); $ie->getTextBox("name:", "upfile")->SetValue("C:\\qctool.jar"); $ie->WaitforDone;

The above code works for a normal textbox of type text now see the below code

<html> <head> </head> <body> File to upload: <INPUT TYPE=FILE NAME="upfile"><BR> <INPUT TYPE=SUBMIT VALUE="Submit"> </body> </html>

Use the same perl code

use strict; use Win32::IEAutomation; use warnings; my $ie = Win32::IEAutomation->new( visible => 1, maximize => 1); $ie->gotoURL('C:\ex.html'); $ie->getTextBox("name:", "upfile")->SetValue("C:\\qctool.jar"); $ie->WaitforDone;

Update: The $ie->getTextBox("name:", "upfile")->SetValue("C:\\qctool.jar");does not work for the input type = file. What shall i do to recover this

Note dear monks: IT seems there is an issue with upload file when the setvalue transfers the file path the OS does not recognizes it since the input type is file the OS accepts value only from the internal browse command but it skips the setvalue->()'s value. This happened with me in perl/tk too. When i used perl/tk $but = $frame_figurecheck1 -> Button (-text => "Browse", -command =>sub{getOpenFile()});when this line is executed in perl/tk the $but is not assigned with the selected value i mean the selected file path

Update: As thomas895 said to try this code

use diagnostics; if( my $textbox = $ie->getTextBox('name:', 'ctl00$ContentPlaceHolderCo +ntent$FileUpload_opfFile') ) { #Okay, now see if we can set the value if( $textbox->SetValue('C:\\test\\9780547076034NIMAS.opf') ) { print "it should work\n"; } else { print "could not set the value\n"; } } else { print "could not get the text box\n"; }

The output of my code was "could not set the value" any idea about this monks


In reply to use Win32::IEAutomation; by sharief

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.