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
In reply to use Win32::IEAutomation; by sharief
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |