Jump to content

How to set value to a textarea on a site, when it can't find the formname.


Go to solution Solved by DW1,

Recommended Posts

Hey All,

I ran into a slight problem on a website.  I tried the code in the help file to help find the forms with _ieformgetcollection on this website and it says there are zero forms in the message box.  The code on the site say's the form name but it can't access it for some strange reason.

I was confused by this as I haven't ran into the problem yet.  Is there another way to be able to set my reference into this text area "myPronList"?  It says the form name is "_ct10" which is really odd.  In the past I would have just gotten the form name and _ieformelementgetobjbyname and set the value, but it seems even though it's named it can't find any forms.

Here is the source code on the site.  Thanks in advance!

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML Transitional//EN"><META http-equiv="Content-Type" content="text/html; charset=windows-1252">

<html>

<head><style>

td.clsInput

{

font-family: Arial;

font-size: 11px;

border-top-color: currentColor;

border-right-color: currentColor;

border-top-width: medium;

border-right-width: medium;

border-top-style: none;

border-right-style: none;

background-color: rgb(182, 221, 186);

}

.clsInput

{

font-family: Verdana;

font-size: 11px;

background-color: rgb(182, 221, 186);

}

.inputPronumBox

{

width: 95%;

height: 150px;

}

</style></head>

<body topmargin="0" leftmargin="0"><form name="_ctl0" id="_ctl0" action="/p2001web/prosearch.net/prosearch.aspx?refcode=%5dmo%5d%5dpst7_4K5T_%7bQ_4K5T_4K5T_gdHDHF&overwriteCUSTCODE=" method="post"><div id="panel1" style="position: relative;"><table width="700" id="myTableGrid" bgcolor="black" cellspacing="1" cellpadding="1"><tbody><tr><td width="75%" align="middle" class="clsInput" valign="top">

<textarea name="myPronList" class="inputPronumBox" id="myPronList"></textarea>

</td></tr></tbody></table></div></form></body></html>

Link to comment
Share on other sites

#include <IE.au3>
#include <Excel.au3>
#include <Array.au3>


$row = 3
$result = "F:EIDFWNATOracle NMCNMC DevelopmentNetwork AnalystReportsautoitCTSI Tracking Tool.xlsx"
$oExcel = _ExcelBookOpen($result)
$aArray = _ExcelReadSheetToArray($oExcel)
$counter = $aArray[0][0]
$oie = _IECreate("https://ww5.ctsi-global.com/www/login/index.asp",0,1,1)
$lform = _IEFormGetObjByName($oie,"fabpLoginForm")
$uname = _IEFormElementGetObjByName($lform, "username")
$pw = _IEFormElementGetObjByName($lform, "password")
_IEFormElementSetValue($uname, "dfdf")
_IEFormElementSetValue($pw, "dfdf")
_IEFormImageClick($oie, "images/aqua_submit_button.gif")
_IELoadWait($oie)
Do
$c1 = 1
$invoice = $aArray[$row][$c1]
_IELoadWait($oie)
$oForm = _IEFormGetObjByName($oIE, "ct10")
$search = _IEFormElementGetObjByName($oForm, "myPronList")
_IEFormElementSetValue($search, $invoice)
;$status = $invarray[1][5]
;$payment = $invarray[1][4]
;$checknum = $invarray[1][6]
;$diff = ($payment - $cost)
;_ExcelWriteCell($oExcel, $status, $row, 3)
;_ExcelWriteCell($oExcel, $payment, $row, 4)
;_ExcelWriteCell($oExcel, $checknum, $row, 5)
;_ExcelWriteCell($oExcel, "=D"&$row&"-B"&$row, $row, 6)
;_ExcelWriteCell($oExcel, $diff , $row, 6)
;Else
;_ExcelWriteCell($oExcel, "Not Found", $row, 4)
;EndIf
;_IENavigate($oIE, "https://ww5.ctsi-global.com/p2001web/default_carrier.asp",1)
_IELoadWait($oie)
$row = $row + 1
Until $row = $counter + 1
MsgBox("", "", "done")

 

Here you go. Stuck on not being able to set my $invoice variable in the textarea.  Thanks!

Edited by dar100111
Link to comment
Share on other sites

_IEFormGetCollection didn't return 0 forms for me...

#include <IE.au3>
Local $sURL = 'C:\Scripts\TEST\test.html'
Local $oIE = _IECreate($sURL)
Local $oForm = _IEFormGetObjByName($oIE, '_ctl0')
Local $oTextArea = _IEFormElementGetObjByName($oForm, 'myPronList')
_IEFormElementSetValue($oTextArea, 'myPronList is a funny name')
Link to comment
Share on other sites

Hey Dan,  What's the easiest way to copy all the html and paste it into here.  I'm using the developer tool with IE and I can only copy one tag at a time.

Thanks!

Just use File > SaveAs > "Webpage, HTML only" in Internet Explorer.  Then attach the html file to a reply.

Link to comment
Share on other sites

Untested as the html file provided didn't have much to it.

#include <IE.au3>
Local $sURL = 'C:\Scripts\TEST\test.html'
Local $oIE = _IECreate($sURL)
;Local $oFrame = _IEFormGetObjByName($oIE, 'main');--Corrected this typo below
Local $oFrame = _IEFrameGetObjByName($oIE, 'main')
Local $oForm = _IEFormGetObjByName($oFrame, '_ctl0')
Local $oTextArea = _IEFormElementGetObjByName($oForm, 'myPronList')
_IEFormElementSetValue($oTextArea, 'myPronList is a funny name')

If that doesn't work, run this and paste the console output:

Local $oIE = _IECreate($sURL)
Local $oFrames = _IEFrameGetCollection($oIE)
Local $iNumFrames = @extended
For $i = 0 To ($iNumFrames - 1)
    Local $oFrame = _IEFrameGetCollection($oIE, $i)
    ConsoleWrite('Frame ' & $i & ' = ' & $oFrame.name & @CRLF)
Next
Edited by danwilli
Link to comment
Share on other sites

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<HTML>

<HEAD>

<title>CTSI's Prosearch</title>

<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">

<meta content="C#" name="CODE_LANGUAGE">

<meta content="JavaScript" name="vs_defaultClientScript">

<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">

<LINK id="ProsearchCSS" href="prosearch.css" type="text/css" rel="stylesheet"></LINK>

<style>

.inputPronumBox{

width: 95%;

height: 150px

}

.displaynone{

display:none;

}

</style>

</HEAD>

<body leftMargin="0" topMargin="0">

<form name="_ctl0" method="post" action="/p2001web/prosearch.net/prosearch.aspx?refcode=%5dmo%5d%5dpst7_4K5T_%7bQ_4K5T_4K5T_gdHDHF&amp;overwriteCUSTCODE=" id="_ctl0">

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPaA8FDzhkMDRmNjYwZTk4NmFiYmQBmEbN2idRFnlzIqOBvgghx82GOQ==" />

<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAwK91KTOCwKTvvm6CwKRq/PlB2e2R0+3jqm9fL6HPa4eiugVJNTH" />

<table width="700" border="0">

<tr>

<td class="prgTitle" align="middle" width="50%"><span id="myPageHeader_myTitleHdr">Prosearch</span></td>

<td align="right"><IMG src="topcomp.gif" border="0"></td>

</tr>

</table>

<!---Panel1--><div id="panel1" style="POSITION: relative">

<table id="myTableGrid" cellspacing="1" cellpadding="1" width="700" bgcolor="black">

<tr>

<TD class="clsTitle" valign="top" align="right" width="25%">Enter pronumber(s)

</TD>

<TD class="clsInput" valign="top" align="middle" width="75%">

<textarea name="myPronList" id="myPronList" class="inputPronumBox"></textarea></TD>

</tr>

<tr>

<TD class="clsTitle" align="middle" colspan="2">

<input type="submit" name="mySubmit" value="Search" id="mySubmit" class="Button1" />

<INPUT class="button1" type="reset" value="Clear">

</TD>

</tr>

</table>

<div id="divCheckResearch" style="font-size:14px">

<a href="checksearch.aspx?refcode=]mo]]pst7_4K5T_{Q_4K5T_4K5T_gdHDHF">Switch to Check Research</a>

<br><br>

</div>

<span id="carrierMsg"><FONT style="FONT-SIZE: 14px" face="verdana" color="green">Attention: Your mailback report of rejected invoices is now available on this web site. On the top menu bar there is "Mailback" link. This link directs you to a page containing a collection of your mailback reports. </FONT><br> <br/><font style="font-family:verdana;font-size:12px"><a href="../../documents/CarrierDocs/Mailback_reasons_for_Intel.xls>Reject reasons</a><br/><br/>

NOTE: Amount received may be reduced due to intermediate banking fees.</font><br/><br/><font style="font-family:verdana;font-size:12px">NOTE: For CASE NEW HOLLAND, <a href="specialMessage/sp0344.htm" target="_blank"> Click Here </a> to see the Escalation tree for Payment Issues.</font></span>

</div>

<!---Panel2-->

<!---Panel3-->

<span id="lblLinkToProdetail"><font face="tahoma" color="Blue"></font></span>

<span id="errorMsg"></span>

 

</form>

<script language="javascript">

function ShowImage(pImageParam){

var tarURL = "/P2001web/ShowImage/default.aspx?"+ pImageParam;

window.open(tarURL,'ImageProsearch','width=600,height=400, resizable=yes');

}

 

function SendToProdetail(batch,seqnum,custno,pronum,flag,shortstatus, userid,LegacyParam){

// window.status = batch + " " + seqnum + " " +custno + " " + pronum + " " + flag + " " + shortstatus + " " + userid;

var hostname = window.location.hostname;

var myPkey = getPkey(batch,seqnum);

myURL = "/p2001web/scenpro2/prodetailview.asp?prodetail_USERID=" + escape(userid) + "&prodetail_CUSTCODE=" + custno + "&searchField=pronum&searchValue=" + pronum + "&externalCallFlag=1&pkey=" + myPkey + "&LegacyParam=" + LegacyParam;

var myX = 725;

var myY = 500;

var myLeft = (screen.availWidth-myX)/2;

var myTop = (screen.availHeight-myY)/2;

//alert(myURL);

window.open(myURL,'prodetailview',"width="+myX+",height="+myY+",top="+myTop+",left="+myLeft+",location=no,status=no,status=yes,scrollbars=yes");

}

function getPkey(batch,seqnum){

var newseqno = "";

for(var i = 0; i < 8-seqnum.length; i++){

newseqno += "0";

}

newseqno += seqnum;

return(batch+newseqno);

}

function highlightThis(thisObj,thisOn){

if(thisOn == 1){

thisObj.parentNode.parentNode.className = "clsHighlight1"

}else{

if(thisObj.parentNode.parentNode.rowIndex % 2 == 0){

thisObj.parentNode.parentNode.className = "clsInputAlternate";

}else{

thisObj.parentNode.parentNode.className = "clsInput";

}

}

}

function detailThisRow(thisObj){

markThis(thisObj);

eval(thisObj.parentNode.parentNode.childNodes(0).childNodes(0).childNodes(0).href);

}

function markThis(thisObj){

thisObj.parentNode.parentNode.childNodes(0).childNodes(0).childNodes(0).className = "Mark";

}

 

if(window.opener != null){

window.focus();

try{

window.resizeTo(document.getElementById("prosearchDetailSTD").clientWidth+15,document.getElementById("prosearchDetailSTD").clientHeight+130);

}catch(e) { a =1; }

}

function adjustIFrameSize(iframeWindow) {

if (iframeWindow.document.height) {

var iframeElement = document.getElementById(iframeWindow.name);

iframeElement.style.height = iframeWindow.document.height + 'px';

iframeElement.style.width = iframeWindow.document.width + 'px';

}

else if (document.all) {

var iframeElement = document.all[iframeWindow.name];

if (iframeWindow.document.compatMode &&

iframeWindow.document.compatMode != 'BackCompat') {

iframeElement.style.height = iframeWindow.document.documentElement.scrollHeight + 5 + 'px';

iframeElement.style.width = iframeWindow.document.documentElement.scrollWidth + 5 + 'px';

}

else {

iframeElement.style.height = iframeWindow.document.body.scrollHeight + 5 + 'px';

iframeElement.style.width = iframeWindow.document.body.scrollWidth + 5 + 'px';

}

}

}

function openPDFDoc(thisURL) {

width = 640;

height = 480;

var str = "height=" + height + ",innerHeight=" + height;

str += ",width=" + width + ",innerWidth=" + width;

if (window.screen) {

var ah = screen.availHeight - 30;

var aw = screen.availWidth - 10;

var xc = (aw - width) / 2;

var yc = (ah - height) / 2;

str += ",left=" + xc + ",screenX=" + xc;

str += ",top=" + yc + ",screenY=" + yc;

}

if (thisURL.toLowerCase().indexOf(".htm") > 0) {

str += ",resizable=yes,menubar=yes,status=yes,toolbar=yes";

} else {

str += ",resizable=yes,menubar=yes,status=no";

}

thisLoc = '../../docviewer/docPDFLoader.asp?thisURL=' + thisURL + '&thisTitle=EOW Report&date' + Date();

document.getElementById("iframeSaveFile").src = thisLoc;

//window.open(thisLoc);

}

</script>

</body>

</HTML>

Link to comment
Share on other sites

Here you go Dan.  Thanks for being patient too.

 

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:Usersdfw-danielroDesktopCTSI Tracking Script (Cindy).au3" /UserParams   
+>12:52:33 Starting AutoIt3Wrapper v.2.1.2.9    Environment(Language:0409  Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64)
>Running AU3Check (1.54.22.0)  from:C:Program Files (x86)AutoIt3
+>12:52:33 AU3Check ended.rc:0
>Running:(3.3.8.1):C:Program Files (x86)AutoIt3autoit3.exe "C:Usersdfw-danielroDesktopCTSI Tracking Script (Cindy).au3"   
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
Frame 0 = banner
Frame 1 = left
Frame 2 = main
 

Link to comment
Share on other sites

Okay, so there are three forms on the page.  I figured that this element was within main, but maybe not.  What was the scite console output of the first script in the same post... this one:

#include <IE.au3>
Local $sURL = 'C:\Scripts\TEST\test.html'
Local $oIE = _IECreate($sURL)
Local $oFrame = _IEFormGetObjByName($oIE, 'main')
Local $oForm = _IEFormGetObjByName($oFrame, '_ctl0')
Local $oTextArea = _IEFormElementGetObjByName($oForm, 'myPronList')
_IEFormElementSetValue($oTextArea, 'myPronList is a funny name')
Link to comment
Share on other sites

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:Usersdfw-danielroDesktopCTSI Tracking Script (Cindy).au3" /UserParams

+>13:02:46 Starting AutoIt3Wrapper v.2.1.2.9 Environment(Language:0409 Keyboard:00000409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64)

>Running AU3Check (1.54.22.0) from:C:Program Files (x86)AutoIt3

+>13:02:46 AU3Check ended.rc:0

>Running:(3.3.8.1):C:Program Files (x86)AutoIt3autoit3.exe "C:Usersdfw-danielroDesktopCTSI Tracking Script (Cindy).au3"

--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop

--> IE.au3 V2.4-0 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch

--> IE.au3 V2.4-0 Error from function _IEFormGetObjByName, $_IEStatus_InvalidDataType

--> IE.au3 V2.4-0 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType

--> IE.au3 V2.4-0 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType

+>13:03:07 AutoIt3.exe ended.rc:0

>Exit code: 0 Time: 21.112

Link to comment
Share on other sites

That doesn't add up for me.  You posted the other output which stated "main" was a form name, but now we are getting an error stating there was no match on that form name: "--> IE.au3 V2.4-0 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch".  You did correct the URL right?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...