sharief has asked for the wisdom of the Perl Monks concerning the following question:
This is the source html tag <input type="file" name="ctl00$ContentPlaceHolderContent$FileUpload_op +fFile" id="ctl00_ContentPlaceHolderContent_FileUpload_opfFile" style= +"width:406px;" />
There is no change to the textbox were we upload a file any help on this... I used all the possibilities likeuse 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();
$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"> <br /> <input type="submit" name="ctl00$ContentPl +aceHolderContent$btnPullMetadata" value="Validate & Populate Fiel +ds Below" onclick="javascript:WebForm_DoPostBackWithOptions(new WebFo +rm_PostBackOptions("ctl00$ContentPlaceHolderContent$btnPullMetad +ata", "", true, "vgOPFValidation", "&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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: use Win32::IEAutomation;
by Khen1950fx (Canon) on Dec 26, 2011 at 13:26 UTC | |
by johngg (Canon) on Dec 26, 2011 at 18:10 UTC | |
by tye (Sage) on Dec 28, 2011 at 16:55 UTC | |
|
Re: use Win32::IEAutomation;
by ww (Archbishop) on Dec 27, 2011 at 11:52 UTC | |
by sharief (Novice) on Dec 27, 2011 at 12:01 UTC | |
by ww (Archbishop) on Dec 27, 2011 at 12:16 UTC | |
by tye (Sage) on Dec 28, 2011 at 16:48 UTC | |
|
Re: use Win32::IEAutomation;
by poj (Abbot) on Dec 27, 2011 at 10:32 UTC | |
by sharief (Novice) on Dec 27, 2011 at 10:44 UTC | |
by poj (Abbot) on Dec 27, 2011 at 11:43 UTC | |
|
Re: use Win32::IEAutomation;
by Xiong (Hermit) on Dec 27, 2011 at 11:28 UTC | |
|
Re: use Win32::IEAutomation;
by poj (Abbot) on Dec 29, 2011 at 12:59 UTC | |
|
Re: use Win32::IEAutomation;
by poj (Abbot) on Dec 28, 2011 at 15:46 UTC | |
|
Re: use Win32::IEAutomation;
by thomas895 (Deacon) on Dec 29, 2011 at 10:11 UTC | |
by sharief (Novice) on Dec 29, 2011 at 10:41 UTC | |
by thomas895 (Deacon) on Dec 29, 2011 at 20:06 UTC |