Jump to content

_IEFormElementSetValue for second form?


MichaelO
 Share

Recommended Posts

I'm having trouble setting a textbox value for a second form.

This is the scenario:

I want to logon to a web-based application (first entering and submitting credentials ) and then populate a search box and submit it.

The url I have goes to the search page, after the logon credentials are passed.

To logon, I have the following code, logs me in without issue, and presents me with the page that has the search box and submit button:

$webpage = "http://mypagegoeshere/"  ;name of web page to open

;these are the form and field names for the login screen
$myForm = "login" ;name of form
$myUserField = "userid";name of username field - found using 'view source' and searching for 'user'
$myPWField = "pwd" ;name of password field - found using 'view source' and searching for 'password'
$myLoginWindow="My Page"

;this is where the user credentials are stored
$myPasswordINI="c:\michaeltest.ini";name of text file containing usernames/passwords
$myApp="App"
$myEncryptPassword="testme"
$myUsername = IniRead($myPasswordINI, $myApp, "Username",  "")
$myPassword = _StringEncrypt(0,IniRead($myPasswordINI, $myApp, "Password",  ""),$myEncryptPassword,2)

$oIE = _IECreate($webpage)
$oForm = _IEFormGetObjByName($oIE, $myForm)
$oQueryUSER = _IEFormElementGetObjByName($oForm, $myUserField)
$oQueryPWD = _IEFormElementGetObjByName($oForm, $myPWField)
_IEFormElementSetValue($oQueryUSER, $myUsername)
_IEFormElementSetValue($oQueryPWD, $myPassword)
$oSubmit = _IEGetObjByName($oIE, "submit")
_IEAction($oSubmit, "click")

Once the page loads, I have a search screen with a second form (win0) and a field (PROJ_SRCH_PROJECT_ID) that I want to populate with a number (currently testing with $myProject)

I tried to follow the same syntax as the login screen, but that uses _IECreate, so a new window opens.

$oIE = _IECreate($webpage)
$myProjectSearchForm="win0"
$myProjectIDField="PROJ_SRCH_PROJECT_ID"
$myProject="000010003900"
$oForm_Proj = _IEFormGetObjByName($oIE, $myProjectSearchForm)
$oQueryProjectID = _IEFormElementGetObjByName($oForm_Proj, $myProjectIDField)
_IEFormElementSetValue($oQueryProjectID, $myProject)

I tried removing the _IECreate($webpage), but that doesn't help either.

Assuming I have the correct object names, does anyone know how I can set the value of the field without using _IECreate? And/or can anyone nudge me in the right direction?

Thanks for your help!

Link to comment
Share on other sites

Try using _IEAttach() instead.

Does this work?

_IELoadWait($oIE)
;~ $oIE = _IEAttach($webpage,"URL")
;~ $myProjectSearchForm="win0"
$myProjectIDField="PROJ_SRCH_PROJECT_ID"
$myProject="000010003900"
$oForm_Proj = _IEGetObjByName($oIE,"PROJ_SRCH_PROJECT_ID")
;~ $oQueryProjectID = _IEFormElementGetObjByName($oForm_Proj, $myProjectIDField)
_IEFormElementSetValue($oForm_Proj, $myProject)

Also, I can see you are using the same variables, so I assume both codes are part of the same script. If that's so, then why do you need to create the explorer again?

Edited by Nahuel
Link to comment
Share on other sites

Try using _IEAttach() instead.

Does this work?

_IELoadWait($oIE)
;~ $oIE = _IEAttach($webpage,"URL")
;~ $myProjectSearchForm="win0"
$myProjectIDField="PROJ_SRCH_PROJECT_ID"
$myProject="000010003900"
$oForm_Proj = _IEGetObjByName($oIE,"PROJ_SRCH_PROJECT_ID")
;~ $oQueryProjectID = _IEFormElementGetObjByName($oForm_Proj, $myProjectIDField)
_IEFormElementSetValue($oForm_Proj, $myProject)

Also, I can see you are using the same variables, so I assume both codes are part of the same script. If that's so, then why do you need to create the explorer again?

Sorry for being a little slow here - I'm new at this. The logic for the login page worked for me, so I was trying to emulate it without thoroughly understanding what it does. Indeed, I do not need to create another explorer window. In fact, I specifically don't want to create a new window. And I don't think I want to use _IEAttache either, because it is already the active window in the script. I just want to populate the field on the displayed page, and submit the search query.

I tried your suggestion, but it still doesn't work.

Here's what is confusing me: when I create the new explorer page, I am presented with a form (login) that has fields (username and password). Once I pass the credentials, I am presented with a second page that has a different form name (win0) and different fields (the one I want to use has a class of PSEDITBOX an id of PROJ_SRCH_PROJECT_ID a name of PROJ_SRCH_PROJECT_ID and a tag index of 17. (FYI - None of this information is visible using the AutoIT Window Info program. I'm getting it using the DOM explorer from the IE Developer Toolbar.)

I would assume that I need to reference both the form and the field as on the login page, but I guess I just don't understand what that logic is doing, or how the syntax should read.

Thanks!

Link to comment
Share on other sites

I use DebugBar (www.debugbar.com).

If you say that the name of the input box is "PROJ_SRCH_PROJECT_ID" then this should work:

$myProjectIDField="PROJ_SRCH_PROJECT_ID"
$myProject="000010003900"
$oForm_Proj = _IEGetObjByName($oIE,$myProjectIDField)
_IEFormElementSetValue($oForm_Proj, $myProject)

Now what exactly doesn't work? Is the text not set in the input box? Or what happens?

This is an example I made (very similar to the one in the Help File) so you can see the steps it takes:

#include <IE.au3>
;Create the IE
$oIE = _IECreate ("http://www.google.com")

;Get the input object called 'q'
$oQuery= _IEGetObjByName ($oIE, "q")

;Get the button object called 'btnG' (Search in Google)
$oButton= _IEGetObjByName ($oIE, "btnG")

;Set the text in the input
_IEFormElementSetValue ($oQuery, "This is an example")

;Click on the button
_IEAction($oButton,"click")
Link to comment
Share on other sites

Hi,

I downloaded, installed and used debugbar. It shows the same information that the IE Developer Toolbar showed:

Both the 'name' and 'id' for the textbox I want to populate is PROJ_SRCH_PROJECT_ID

I tried this, assuming the $oIE from the _IECreate would still be in memory (what is this value? I tried msgbox, and it resolves to null or empty?):

$myProjectIDField="PROJ_SRCH_PROJECT_ID"
$myProject="000010003900"
$oQuery= _IEGetObjByName ($oIE, $myProjectIDField)
_IEFormElementSetValue ($oQuery, $myProject)

When I run this code (which follows the code I included earlier), no fields are populated. If I put a msgbox statement right before the _IEFormElementSetValue statement, it properly resolves both $myProjectIDField and $myProject to the names I assigned them. However, I can't get the field to actually be valued.

I think the problem may be the form name. I think it is called "win0", but when I used a varation of the example for _IEFormGetCollection, I don't receive the expected form name. The output I get is "There are 1 forms on this page" and then it quits. I never get to see how $oForm.name resolves.

$oForms = _IEFormGetCollection ($oIE)
MsgBox(0, "Forms Info", "There are " & @extended & " forms on this page")
For $oForm In $oForms
    MsgBox(0, "Form Info", $oForm.name)
Next

Do you have any other suggestions?

Thanks!

Link to comment
Share on other sites

Well, could it be possible for you to show me the page's code? I think it's really weird that it doesn't work with this code:

$myProjectIDField="PROJ_SRCH_PROJECT_ID"
$myProject="000010003900"
$oQuery= _IEGetObjByName ($oIE, $myProjectIDField)
_IEFormElementSetValue ($oQuery, $myProject)

This code is independent from the form name...

Link to comment
Share on other sites

Well, could it be possible for you to show me the page's code? I think it's really weird that it doesn't work with this code:

$myProjectIDField="PROJ_SRCH_PROJECT_ID"
$myProject="000010003900"
$oQuery= _IEGetObjByName ($oIE, $myProjectIDField)
_IEFormElementSetValue ($oQuery, $myProject)

This code is independent from the form name...

Hi Nahuel,

There is a lot of code on this page. I have limited the paste to the form in question. Let me know if you need the entire page, and I will attach it as a text file.

<FORM name=win0 action=../../../EMPLOYEE/ERP/c/CREATE_PROJECTS.PROJECT_GENERAL.GBL method=post autocomplete="off"><INPUT type=hidden value=Panel name=ICType> <INPUT type=hidden value=0 name=ICElementNum> <INPUT type=hidden value=1 name=ICStateNum> <INPUT type=hidden value=None name=ICAction> <INPUT type=hidden value=0 name=ICXPos> <INPUT type=hidden value=0 name=ICYPos> <INPUT type=hidden name=ICFocus> <INPUT type=hidden value=-1 name=ICChanged> <INPUT type=hidden value=0 name=ICResubmit> 
<DIV id=PAGEBAR>
<TABLE cellSpacing=0 cols=3 cellPadding=0 width="100%" vspace="0" hspace="0">
<TBODY>
<TR>
<TD width="80%"></TD>
<TD noWrap align=right width="10%"></TD>
<TD noWrap align=right width="10%"><A class=PSHYPERLINK id=NEWWIN tabIndex=1 href="java script:processing_win0(0,3000); void window.open('http://myWebPage/psp/fss88prd_newwin/EMPLOYEE/ERP/c/CREATE_PROJECTS.PROJECT_GENERAL.GBL','','');" name=NEWWIN PSaccesskey="9">New Window</A> | <A class=PSHYPERLINK id=HELP tabIndex=2 href="java script:void window.open('http://myWebPage:6001/PSOL/htmldoc/f1search.htm?ContextID=25000&LangCD=ENG','help','');" name=HELP>Help</A> | <A id=COPYURL tabIndex=3 href="java script:CopyUrlToClipboard();" name=COPYURL><IMG title="Click to copy the complete address (URL) of this page to the clipboard." alt="Click to copy the complete address (URL) of this page to the clipboard." hspace=0 src="/cs/fss88prd/cache/PT_COPYURL_IMG_1.gif" align=absMiddle border=0></A></TD></TR></TBODY></TABLE><BR></DIV><SPAN class=PSSRCHTITLE>General Information</SPAN><BR><SPAN class=PAPAGEINSTRUCTIONS>Enter any information you have and click Search. Leave fields blank for a list of all values.</SPAN> <BR><BR>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD><IMG class=PSNOIMAGE alt="" src="/cs/fss88prd/cache/PT_TAB1LAX_1.gif"></TD>
<TD><IMG class=PSNOIMAGE style="WIDTH: 100%" height=1 alt="" src="/cs/fss88prd/cache/PT_TAB1MAX_1.gif" width="100%"></TD>
<TD><IMG class=PSNOIMAGE alt="" src="/cs/fss88prd/cache/PT_TAB1RAX_1.gif"></TD>
<TD rowSpan=2></TD></TR>
<TR>
<TD><IMG alt="" src="/cs/fss88prd/cache/PT_TAB2LAXFFFFFF_1.gif"></TD>
<TD class=PSACTIVETAB noWrap align=middle>  Find an Existing Value  </TD>
<TD><IMG alt="" src="/cs/fss88prd/cache/PT_TAB2RAXFFFFFF_1.gif"></TD></TR>
<TR>
<TD><IMG alt="" src="/cs/fss88prd/cache/PT_TAB3LAXFFFFFF_1.gif"></TD>
<TD class=PSACTIVETAB></TD>
<TD><IMG alt="" src="/cs/fss88prd/cache/PT_TAB3RAXFFFFFF_1.gif"></TD>
<TD><IMG class=PSBOTTOMLINE style="BORDER-LEFT-COLOR: #ffffff; BORDER-BOTTOM-COLOR: #ffffff; WIDTH: 465px; BORDER-TOP-COLOR: #ffffff; BORDER-RIGHT-COLOR: #ffffff" alt="" src="/cs/fss88prd/cache/PT_TAB_BOTTOM_LINE_1.GIF" width=465></TD></TR></TBODY></TABLE><BR>
<TABLE class=PSPAGECONTAINER cellSpacing=2 cellPadding=0>
<TBODY>
<TR vAlign=top>
<TD><LABEL class=PSSRCHEDITBOXLABEL for=PROJ_SRCH_BUSINESS_UNIT>Business Unit:</LABEL> </TD>
<TD><SELECT class=PSDROPDOWNLIST tabIndex=12 onchange="if (document.readyState == 'complete') {var tmp=this.options[this.selectedIndex].value;if (tmp=='9' || tmp=='10')submitAction_win0(this.form,this.name);}" name=PROJ_SRCH_BUSINESS_UNIT$op> <OPTION value=2 selected>=</OPTION> <OPTION value=10>in</OPTION></SELECT> </TD>
<TD><INPUT class=PSEDITBOX id=PROJ_SRCH_BUSINESS_UNIT style="WIDTH: 140px" tabIndex=13 maxLength=5 value=01 name=PROJ_SRCH_BUSINESS_UNIT><A id=PROJ_SRCH_BUSINESS_UNIT$prompt tabIndex=14 href="java script:submitAction_win0(document.win0,'PROJ_SRCH_BUSINESS_UNIT$prompt');" name=PROJ_SRCH_BUSINESS_UNIT$prompt><IMG title="Look up Business Unit (Alt+5)" alt="Look up Business Unit (Alt+5)" src="/cs/fss88prd/cache/PT_PROMPT_LOOKUP_2.gif" align=absMiddle border=0></A> </TD></TR>
<TR vAlign=top>
<TD><LABEL class=PSSRCHEDITBOXLABEL for=PROJ_SRCH_PROJECT_ID>Project:</LABEL> </TD>
<TD><SELECT class=PSDROPDOWNLIST tabIndex=16 onchange="if (document.readyState == 'complete') {var tmp=this.options[this.selectedIndex].value;if (tmp=='9' || tmp=='10')submitAction_win0(this.form,this.name);}" name=PROJ_SRCH_PROJECT_ID$op> <OPTION value=1 selected>begins with</OPTION> <OPTION value=8>contains</OPTION> <OPTION value=2>=</OPTION> <OPTION value=3>not =</OPTION> <OPTION value=4><</OPTION> <OPTION value=6><=</OPTION> <OPTION value=5>></OPTION> <OPTION value=7>>=</OPTION> <OPTION value=9>between</OPTION> <OPTION value=10>in</OPTION></SELECT> </TD>
<TD><INPUT class=PSEDITBOX id=PROJ_SRCH_PROJECT_ID style="WIDTH: 140px" tabIndex=17 maxLength=15 name=PROJ_SRCH_PROJECT_ID><A id=PROJ_SRCH_PROJECT_ID$prompt tabIndex=18 href="java script:submitAction_win0(document.win0,'PROJ_SRCH_PROJECT_ID$prompt');" name=PROJ_SRCH_PROJECT_ID$prompt><IMG title="Look up Project (Alt+5)" alt="Look up Project (Alt+5)" src="/cs/fss88prd/cache/PT_PROMPT_LOOKUP_2.gif" align=absMiddle border=0></A> </TD></TR>
<TR vAlign=top>
<TD><LABEL class=PSSRCHEDITBOXLABEL for=PROJ_SRCH_DESCR>Description:</LABEL> </TD>
<TD><SELECT class=PSDROPDOWNLIST tabIndex=20 onchange="if (document.readyState == 'complete') {var tmp=this.options[this.selectedIndex].value;if (tmp=='9' || tmp=='10')submitAction_win0(this.form,this.name);}" name=PROJ_SRCH_DESCR$op> <OPTION value=1 selected>begins with</OPTION> <OPTION value=8>contains</OPTION> <OPTION value=2>=</OPTION> <OPTION value=3>not =</OPTION> <OPTION value=4><</OPTION> <OPTION value=6><=</OPTION> <OPTION value=5>></OPTION> <OPTION value=7>>=</OPTION> <OPTION value=9>between</OPTION> <OPTION value=10>in</OPTION></SELECT> </TD>
<TD><INPUT class=PSEDITBOX id=PROJ_SRCH_DESCR style="WIDTH: 140px" tabIndex=21 maxLength=30 name=PROJ_SRCH_DESCR> </TD></TR>
<TR vAlign=top>
<TD><LABEL class=PSSRCHEDITBOXLABEL for=PROJ_SRCH_PROJECT_USER1>Customer Id:</LABEL> </TD>
<TD><SELECT class=PSDROPDOWNLIST tabIndex=23 onchange="if (document.readyState == 'complete') {var tmp=this.options[this.selectedIndex].value;if (tmp=='9' || tmp=='10')submitAction_win0(this.form,this.name);}" name=PROJ_SRCH_PROJECT_USER1$op> <OPTION value=1 selected>begins with</OPTION> <OPTION value=8>contains</OPTION> <OPTION value=2>=</OPTION> <OPTION value=3>not =</OPTION> <OPTION value=4><</OPTION> <OPTION value=6><=</OPTION> <OPTION value=5>></OPTION> <OPTION value=7>>=</OPTION> <OPTION value=9>between</OPTION> <OPTION value=10>in</OPTION></SELECT> </TD>
<TD><INPUT class=PSEDITBOX id=PROJ_SRCH_PROJECT_USER1 style="WIDTH: 140px" tabIndex=24 maxLength=10 name=PROJ_SRCH_PROJECT_USER1><A id=PROJ_SRCH_PROJECT_USER1$prompt tabIndex=25 href="java script:submitAction_win0(document.win0,'PROJ_SRCH_PROJECT_USER1$prompt');" name=PROJ_SRCH_PROJECT_USER1$prompt><IMG title="Look up Customer Id (Alt+5)" alt="Look up Customer Id (Alt+5)" src="/cs/fss88prd/cache/PT_PROMPT_LOOKUP_2.gif" align=absMiddle border=0></A> </TD></TR>
<TR vAlign=top>
<TD><LABEL class=PSSRCHEDITBOXLABEL for=PROJ_SRCH_NAME1>Customer:</LABEL> </TD>
<TD><SELECT class=PSDROPDOWNLIST tabIndex=27 onchange="if (document.readyState == 'complete') {var tmp=this.options[this.selectedIndex].value;if (tmp=='9' || tmp=='10')submitAction_win0(this.form,this.name);}" name=PROJ_SRCH_NAME1$op> <OPTION value=1 selected>begins with</OPTION> <OPTION value=8>contains</OPTION> <OPTION value=2>=</OPTION> <OPTION value=3>not =</OPTION> <OPTION value=4><</OPTION> <OPTION value=6><=</OPTION> <OPTION value=5>></OPTION> <OPTION value=7>>=</OPTION> <OPTION value=9>between</OPTION> <OPTION value=10>in</OPTION></SELECT> </TD>
<TD><INPUT class=PSEDITBOX id=PROJ_SRCH_NAME1 style="WIDTH: 140px" tabIndex=28 maxLength=40 name=PROJ_SRCH_NAME1> </TD></TR>
<TR vAlign=top>
<TD><LABEL class=PSSRCHEDITBOXLABEL for=PROJ_SRCH_PROJECT_TYPE>Project Type:</LABEL> </TD>
<TD><SELECT class=PSDROPDOWNLIST tabIndex=30 onchange="if (document.readyState == 'complete') {var tmp=this.options[this.selectedIndex].value;if (tmp=='9' || tmp=='10')submitAction_win0(this.form,this.name);}" name=PROJ_SRCH_PROJECT_TYPE$op> <OPTION value=1 selected>begins with</OPTION> <OPTION value=8>contains</OPTION> <OPTION value=2>=</OPTION> <OPTION value=3>not =</OPTION> <OPTION value=4><</OPTION> <OPTION value=6><=</OPTION> <OPTION value=5>></OPTION> <OPTION value=7>>=</OPTION> <OPTION value=9>between</OPTION> <OPTION value=10>in</OPTION></SELECT> </TD>
<TD><INPUT class=PSEDITBOX id=PROJ_SRCH_PROJECT_TYPE style="WIDTH: 140px" tabIndex=31 maxLength=5 name=PROJ_SRCH_PROJECT_TYPE><A id=PROJ_SRCH_PROJECT_TYPE$prompt tabIndex=32 href="java script:submitAction_win0(document.win0,'PROJ_SRCH_PROJECT_TYPE$prompt');" name=PROJ_SRCH_PROJECT_TYPE$prompt><IMG title="Look up Project Type (Alt+5)" alt="Look up Project Type (Alt+5)" src="/cs/fss88prd/cache/PT_PROMPT_LOOKUP_2.gif" align=absMiddle border=0></A> </TD></TR>
<TR vAlign=top>
<TD><LABEL class=PSSRCHDROPDOWNLABEL for=PROJ_SRCH_SUMMARY_PRJ>Program:</LABEL> </TD>
<TD><SELECT class=PSDROPDOWNLIST tabIndex=34 onchange="if (document.readyState == 'complete') {var tmp=this.options[this.selectedIndex].value;if (tmp=='9' || tmp=='10')submitAction_win0(this.form,this.name);}" name=PROJ_SRCH_SUMMARY_PRJ$op> <OPTION value=2 selected>=</OPTION> <OPTION value=3>not =</OPTION> <OPTION value=4><</OPTION> <OPTION value=6><=</OPTION> <OPTION value=5>></OPTION> <OPTION value=7>>=</OPTION> <OPTION value=9>between</OPTION> <OPTION value=10>in</OPTION></SELECT> </TD>
<TD><SELECT class=PSDROPDOWNLIST id=PROJ_SRCH_SUMMARY_PRJ style="WIDTH: 207px" tabIndex=35 size=1 name=PROJ_SRCH_SUMMARY_PRJ> <OPTION value=""></OPTION> <OPTION value=N selected>Detail Project</OPTION> <OPTION value=Y>Program</OPTION></SELECT> </TD></TR></TBODY></TABLE><LABEL for=#ICIncludeHistory><SPAN class=PSSRCHCHECKBOX><INPUT id=#ICIncludeHistory tabIndex=37 type=checkbox value=Y name=#ICIncludeHistory>Include History  </SPAN></LABEL> <LABEL for=#ICMatchCase><SPAN class=PSSRCHCHECKBOX><INPUT id=#ICMatchCase tabIndex=38 type=checkbox value=Y name=#ICMatchCase>Case Sensitive  </SPAN></LABEL> <BR><BR><INPUT class=PSPUSHBUTTONTBSEARCH id=#ICSearch title="Search (Alt+1)" onclick="java script:submitAction_win0(document.win0, '#ICSearch');" tabIndex=39 type=button alt="Search (Alt+1)" value=Search name=#ICSearch>  <INPUT class=PSPUSHBUTTONTBCLEAR id=#ICClear title=Clear onclick="java script:submitAction_win0(document.win0, '#ICClear');" tabIndex=40 type=button alt=Clear value=Clear name=#ICClear>  <A class=PSHYPERLINK tabIndex=41 href="java script: submitAction_win0(document.win0,'#ICAdvSearch');" name=#ICAdvSearch>Basic Search</A> <A class=PSHYPERLINK tabIndex=42 href="java script: submitAction_win0(document.win0,'#ICSaveSearch');" name=#ICSaveSearch><IMG alt="" hspace=5 src="/cs/fss88prd/cache/PT_SAVESEARCH_1.gif" align=middle border=0>Save Search Criteria</A> 
<DIV id=DetachDiv frameborder="0" width="0" height="0"></DIV></FORM>

In addition, I have attached (I think) a screenshot of what the search page looks like. The field I want to populate is the first empty field (Project:).

Thanks!

post-30359-1198021955_thumb.jpg

Link to comment
Share on other sites

Well... using that code, works just perfect for me! I copied that code in notepad and saved it as "test.html". Then I made this:

#include <IE.au3>

$oIE=_IECreate("C:\Documents and Settings\Moni\Escritorio\test.html",1)

$myProjectIDField="PROJ_SRCH_PROJECT_ID"
$myProject="000010003900"
$oQuery= _IEGetObjByName ($oIE, $myProjectIDField)
_IEFormElementSetValue ($oQuery, $myProject)

and...

Posted Image

Link to comment
Share on other sites

Well, could it be possible for you to show me the page's code? I think it's really weird that it doesn't work with this code:

$myProjectIDField="PROJ_SRCH_PROJECT_ID"
$myProject="000010003900"
$oQuery= _IEGetObjByName ($oIE, $myProjectIDField)
_IEFormElementSetValue ($oQuery, $myProject)

This code is independent from the form name...

I don't think I got the whole page code in the last post. Second try...

<html dir='ltr' lang='en'>
<!-- Copyright (c) 2000-2005 All Rights Reserved. -->
<!-- IE/6.0/WINXP; ToolsRel=8.47.07; Page=(search); Component=PROJECT_GENERAL; Menu=CREATE_PROJECTS; User=USERNAME; DB=FSS88PRD/ORACLE; AppServ=//1.1.1.1:9000; -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language='Javascript'>
var  totalTimeoutMilliseconds = 14400000; 
var  warningTimeoutMilliseconds = 14280000; 
var timeOutURL = 'http://MyWebPage/psp/fss88prd/EMPLOYEE/ERP/?cmd=expire';
var timeoutWarningPageURL = 'http://MyWebPage/psc/fss88prd/EMPLOYEE/ERP/s/WEBLIB_TIMEOUT.PT_TIMEOUTWARNING.FieldFormula.IScript_TIMEOUTWARNING';
</script> 

<link rel='stylesheet' type='text/css' href='/cs/fss88prd/cache/PSSTYLEDEF_1.css' />
<title>Project General</title>
<script language='Javascript'>
var baseKey_win0 = "\x1b\r\n";
var altKey_win0 = "\xdc05678\xbc\xbe\xbf\xde\xbc\xbe\xde1";
var ctrlKey_win0 = "JK";
var saveWarningKeys_win0 = "";
var bTabOverTB_win0 = false;
var bTabOverPg_win0 = false;
var bTabOverNonPS_win0 = false;
var strCurrUrl='http://MyWebPage/psp/fss88prd/EMPLOYEE/ERP/c/CREATE_PROJECTS.PROJECT_GENERAL.GBL';
</script>
<script language='Javascript' type='text/javascript' src='/cs/fss88prd/cache/PT_SCRIPTIE600_1.js'>
</script>
<script LANGUAGE='Javascript'>
document.domain = "MyDomain";
</SCRIPT>
<script language='Javascript' type='text/javascript' src='/cs/fss88prd/cache/PT_PAGESCRIPT_win0_1.js'>
</script>
<script language='Javascript' type='text/javascript' src='/cs/fss88prd/cache/PT_COPYURL_1.js'>
</script>
<script language='Javascript' type='text/javascript' src='/cs/fss88prd/cache/PT_ISCROSSDOMAIN_1.js'>
</script>
<script language='Javascript' type='text/javascript' src='/cs/fss88prd/cache/PT_SAVEWARNINGSCRIPT_1.js'>
</script>
<script language='Javascript'>
var nResubmit=0;
setupTimeout();
function submitAction_win0(form, name)
{
form.ICAction.value=name;
form.ICXPos.value=getScrollX();
form.ICYPos.value=getScrollY();
processing_win0(1,3000);
form.ICResubmit.value=nResubmit;
form.submit();
nResubmit++;
}
</script>
<script language='Javascript' type='text/javascript' src='/cs/fss88prd/cache/PT_EDITSCRIPT_win0_1.js'>
</script>
<script language='Javascript' type='text/javascript' src='/cs/fss88prd/cache/PT_EDITSCRIPT2_1.js'>
</script>
</head>
<body class='PSSRCHPAGE'  onload="
setFocus_win0('PROJ_SRCH_BUSINESS_UNIT',-1);
setEventHandlers_win0('ICFirstAnchor_win0', 'ICLastAnchor_win0', false);
processing_win0(0,3000);
setKeyEventHandler_win0();
nResubmit=0;
">
<div id="WAIT_win0" style="position:absolute;right:0;display:block;">
<img align='right' src='/cs/fss88prd/cache/PT_PROCESSING_1.gif' class='PSPROCESSING' alt='Processing... please wait' title='Processing... please wait' />
</div>
<a name='ICFirstAnchor_win0'></a>
<form name='win0' method='post' action="../../../EMPLOYEE/ERP/c/CREATE_PROJECTS.PROJECT_GENERAL.GBL"  autocomplete='off'>
<input type='hidden' name='ICType' value='Panel' />
<input type='hidden' name='ICElementNum' value='0' />
<input type='hidden' name='ICStateNum' value='1' />
<input type='hidden' name='ICAction' value='None' />
<input type='hidden' name='ICXPos' value='0' />
<input type='hidden' name='ICYPos' value='0' />
<input type='hidden' name='ICFocus' value='' />
<input type='hidden' name='ICChanged' value='-1' />
<input type='hidden' name='ICResubmit' value='0' />
<div ID='PAGEBAR'><table cols='3' width='100%' cellpadding='0' cellspacing='0' hspace='0' vspace='0'>
<tr>
<td width='80%'></td><td width='10%' nowrap='nowrap' align='right'></td>
<td width='10%' nowrap='nowrap' align='right'><a ID=NEWWIN NAME=NEWWIN href="java script:processing_win0(0,3000); void window.open('http://MyWebPage/psp/fss88prd_newwin/EMPLOYEE/ERP/c/CREATE_PROJECTS.PROJECT_GENERAL.GBL','','');" PSaccesskey='9' tabindex='1' class='PSHYPERLINK'>New Window</a> | <a id='HELP' name='HELP' href="java script:void window.open('http://MyWebPage:6001/PSOL/htmldoc/f1search.htm?ContextID=25000&LangCD=ENG','help','');" tabindex='2' class='PSHYPERLINK'>Help</a> | <a name='COPYURL' id='COPYURL' tabindex='3' href="java script:CopyUrlToClipboard();"><img src='/cs/fss88prd/cache/PT_COPYURL_IMG_1.gif' border='0' hspace='0' vspace='0' align='absmiddle' alt='Click to copy the complete address (URL) of this page to the clipboard.' title='Click to copy the complete address (URL) of this page to the clipboard.' /></a></td></tr>
</table>
<br />
</div><span class='PSSRCHTITLE'>General Information</span><br />
<span class='PAPAGEINSTRUCTIONS'>Enter any information you have and click Search. Leave fields blank for a list of all values.</span>
<br /><br />
<table border='0' cellpadding='0' cellspacing='0'>
<tr>
<td><img class='PSNOIMAGE' src='/cs/fss88prd/cache/PT_TAB1LAX_1.gif' alt='' /></td>
<td><img class='PSNOIMAGE' style='width:100%;' src='/cs/fss88prd/cache/PT_TAB1MAX_1.gif' width='100%' height='1' alt='' /></td>
<td><img class='PSNOIMAGE' src='/cs/fss88prd/cache/PT_TAB1RAX_1.gif' alt='' /></td>
<td rowspan='2'></td>
</tr>
<tr>
<td><img src='/cs/fss88prd/cache/PT_TAB2LAXFFFFFF_1.gif' alt='' /></td>
<td nowrap='nowrap' align='center' class='PSACTIVETAB'>  Find an Existing Value  </td>
<td><img src='/cs/fss88prd/cache/PT_TAB2RAXFFFFFF_1.gif' alt='' /></td>
</tr>
<tr>
<td><img src='/cs/fss88prd/cache/PT_TAB3LAXFFFFFF_1.gif' alt='' /></td>
<td class='PSACTIVETAB'></td>
<td><img src='/cs/fss88prd/cache/PT_TAB3RAXFFFFFF_1.gif' alt='' /></td>
<td><img class='PSBOTTOMLINE' src='/cs/fss88prd/cache/PT_TAB_BOTTOM_LINE_1.GIF' width='465' alt='' style='width:465px; border-color: #ffffff'/></td>
</tr>
</table>
<br />
<table cellpadding='0' cellspacing='2' class='PSPAGECONTAINER'>
<tr valign='top'>
<td>
<label for='PROJ_SRCH_BUSINESS_UNIT' class='PSSRCHEDITBOXLABEL' >Business Unit:</label>
</td>
<td>
<select name='PROJ_SRCH_BUSINESS_UNIT$op' tabindex='12' class='PSDROPDOWNLIST' onchange="if (document.readyState == 'complete') {var tmp=this.options[this.selectedIndex].value;if (tmp=='9' || tmp=='10')submitAction_win0(this.form,this.name);}">
<option value='2' selected='selected'>=</option>
<option value='10'>in</option>
</select>
</td>
<td>
<input type='text' name='PROJ_SRCH_BUSINESS_UNIT' id='PROJ_SRCH_BUSINESS_UNIT' tabindex='13' value="01" class='PSEDITBOX' style="width:140px; " maxlength='5'  /><a name='PROJ_SRCH_BUSINESS_UNIT$prompt' id='PROJ_SRCH_BUSINESS_UNIT$prompt' tabindex='14' href="java script:submitAction_win0(document.win0,'PROJ_SRCH_BUSINESS_UNIT$prompt');"><img src="/cs/fss88prd/cache/PT_PROMPT_LOOKUP_2.gif" alt='Look up Business Unit (Alt+5)' title='Look up Business Unit (Alt+5)' border='0' align='absmiddle' /></a>
</td>
</tr>
<tr valign='top'>
<td>
<label for='PROJ_SRCH_PROJECT_ID' class='PSSRCHEDITBOXLABEL' >Project:</label>
</td>
<td>
<select name='PROJ_SRCH_PROJECT_ID$op' tabindex='16' class='PSDROPDOWNLIST' onchange="if (document.readyState == 'complete') {var tmp=this.options[this.selectedIndex].value;if (tmp=='9' || tmp=='10')submitAction_win0(this.form,this.name);}">
<option value='1' selected='selected'>begins with</option>
<option value='8'>contains</option>
<option value='2'>=</option>
<option value='3'>not =</option>
<option value='4'><</option>
<option value='6'><=</option>
<option value='5'>></option>
<option value='7'>>=</option>
<option value='9'>between</option>
<option value='10'>in</option>
</select>
</td>
<td>
<input type='text' name='PROJ_SRCH_PROJECT_ID' id='PROJ_SRCH_PROJECT_ID' tabindex='17' value="" class='PSEDITBOX' style="width:140px; " maxlength='15'  /><a name='PROJ_SRCH_PROJECT_ID$prompt' id='PROJ_SRCH_PROJECT_ID$prompt' tabindex='18' href="java script:submitAction_win0(document.win0,'PROJ_SRCH_PROJECT_ID$prompt');"><img src="/cs/fss88prd/cache/PT_PROMPT_LOOKUP_2.gif" alt='Look up Project (Alt+5)' title='Look up Project (Alt+5)' border='0' align='absmiddle' /></a>
</td>
</tr>
<tr valign='top'>
<td>
<label for='PROJ_SRCH_DESCR' class='PSSRCHEDITBOXLABEL' >Description:</label>
</td>
<td>
<select name='PROJ_SRCH_DESCR$op' tabindex='20' class='PSDROPDOWNLIST' onchange="if (document.readyState == 'complete') {var tmp=this.options[this.selectedIndex].value;if (tmp=='9' || tmp=='10')submitAction_win0(this.form,this.name);}">
<option value='1' selected='selected'>begins with</option>
<option value='8'>contains</option>
<option value='2'>=</option>
<option value='3'>not =</option>
<option value='4'><</option>
<option value='6'><=</option>
<option value='5'>></option>
<option value='7'>>=</option>
<option value='9'>between</option>
<option value='10'>in</option>
</select>
</td>
<td>
<input type='text' name='PROJ_SRCH_DESCR' id='PROJ_SRCH_DESCR' tabindex='21' value="" class='PSEDITBOX' style="width:140px; " maxlength='30'  />
</td>
</tr>
<tr valign='top'>
<td>
<label for='PROJ_SRCH_PROJECT_USER1' class='PSSRCHEDITBOXLABEL' >Customer Id:</label>
</td>
<td>
<select name='PROJ_SRCH_PROJECT_USER1$op' tabindex='23' class='PSDROPDOWNLIST' onchange="if (document.readyState == 'complete') {var tmp=this.options[this.selectedIndex].value;if (tmp=='9' || tmp=='10')submitAction_win0(this.form,this.name);}">
<option value='1' selected='selected'>begins with</option>
<option value='8'>contains</option>
<option value='2'>=</option>
<option value='3'>not =</option>
<option value='4'><</option>
<option value='6'><=</option>
<option value='5'>></option>
<option value='7'>>=</option>
<option value='9'>between</option>
<option value='10'>in</option>
</select>
</td>
<td>
<input type='text' name='PROJ_SRCH_PROJECT_USER1' id='PROJ_SRCH_PROJECT_USER1' tabindex='24' value="" class='PSEDITBOX' style="width:140px; " maxlength='10'  /><a name='PROJ_SRCH_PROJECT_USER1$prompt' id='PROJ_SRCH_PROJECT_USER1$prompt' tabindex='25' href="java script:submitAction_win0(document.win0,'PROJ_SRCH_PROJECT_USER1$prompt');"><img src="/cs/fss88prd/cache/PT_PROMPT_LOOKUP_2.gif" alt='Look up Customer Id (Alt+5)' title='Look up Customer Id (Alt+5)' border='0' align='absmiddle' /></a>
</td>
</tr>
<tr valign='top'>
<td>
<label for='PROJ_SRCH_NAME1' class='PSSRCHEDITBOXLABEL' >Customer:</label>
</td>
<td>
<select name='PROJ_SRCH_NAME1$op' tabindex='27' class='PSDROPDOWNLIST' onchange="if (document.readyState == 'complete') {var tmp=this.options[this.selectedIndex].value;if (tmp=='9' || tmp=='10')submitAction_win0(this.form,this.name);}">
<option value='1' selected='selected'>begins with</option>
<option value='8'>contains</option>
<option value='2'>=</option>
<option value='3'>not =</option>
<option value='4'><</option>
<option value='6'><=</option>
<option value='5'>></option>
<option value='7'>>=</option>
<option value='9'>between</option>
<option value='10'>in</option>
</select>
</td>
<td>
<input type='text' name='PROJ_SRCH_NAME1' id='PROJ_SRCH_NAME1' tabindex='28' value="" class='PSEDITBOX' style="width:140px; " maxlength='40'  />
</td>
</tr>
<tr valign='top'>
<td>
<label for='PROJ_SRCH_PROJECT_TYPE' class='PSSRCHEDITBOXLABEL' >Project Type:</label>
</td>
<td>
<select name='PROJ_SRCH_PROJECT_TYPE$op' tabindex='30' class='PSDROPDOWNLIST' onchange="if (document.readyState == 'complete') {var tmp=this.options[this.selectedIndex].value;if (tmp=='9' || tmp=='10')submitAction_win0(this.form,this.name);}">
<option value='1' selected='selected'>begins with</option>
<option value='8'>contains</option>
<option value='2'>=</option>
<option value='3'>not =</option>
<option value='4'><</option>
<option value='6'><=</option>
<option value='5'>></option>
<option value='7'>>=</option>
<option value='9'>between</option>
<option value='10'>in</option>
</select>
</td>
<td>
<input type='text' name='PROJ_SRCH_PROJECT_TYPE' id='PROJ_SRCH_PROJECT_TYPE' tabindex='31' value="" class='PSEDITBOX' style="width:140px; " maxlength='5'  /><a name='PROJ_SRCH_PROJECT_TYPE$prompt' id='PROJ_SRCH_PROJECT_TYPE$prompt' tabindex='32' href="java script:submitAction_win0(document.win0,'PROJ_SRCH_PROJECT_TYPE$prompt');"><img src="/cs/fss88prd/cache/PT_PROMPT_LOOKUP_2.gif" alt='Look up Project Type (Alt+5)' title='Look up Project Type (Alt+5)' border='0' align='absmiddle' /></a>
</td>
</tr>
<tr valign='top'>
<td>
<label for='PROJ_SRCH_SUMMARY_PRJ' class='PSSRCHDROPDOWNLABEL' >Program:</label>
</td>
<td>
<select name='PROJ_SRCH_SUMMARY_PRJ$op' tabindex='34' class='PSDROPDOWNLIST' onchange="if (document.readyState == 'complete') {var tmp=this.options[this.selectedIndex].value;if (tmp=='9' || tmp=='10')submitAction_win0(this.form,this.name);}">
<option value='2'>=</option>
<option value='3'>not =</option>
<option value='4'><</option>
<option value='6'><=</option>
<option value='5'>></option>
<option value='7'>>=</option>
<option value='9'>between</option>
<option value='10'>in</option>
</select>
</td>
<td>
<select name='PROJ_SRCH_SUMMARY_PRJ' id='PROJ_SRCH_SUMMARY_PRJ' tabindex='35' size='1' class='PSDROPDOWNLIST' style="width:207px; " >
<option value=""></option>
<option value="N" selected='selected'>Detail Project</option>
<option value="Y">Program</option>
</select>
</td>
</tr>
</table>
<label for='#ICIncludeHistory'><span class='PSSRCHCHECKBOX'>
<input type='checkbox' name='#ICIncludeHistory' id='#ICIncludeHistory' value='Y' tabindex='37' />Include History  </span></label>
<label for='#ICMatchCase'><span class='PSSRCHCHECKBOX'>
<input type='checkbox' name='#ICMatchCase' id='#ICMatchCase' value='Y' tabindex='38' />Case Sensitive  </span></label>
<br />
<br /><input type=button id='#ICSearch' name='#ICSearch'  class='PSPUSHBUTTONTBSEARCH' value='Search' onclick="java script:submitAction_win0(document.win0, '#ICSearch');" tabindex='39' alt='Search (Alt+1)' title='Search (Alt+1)'> 
<input type=button id='#ICClear' name='#ICClear'  class='PSPUSHBUTTONTBCLEAR' value='Clear' onclick="java script:submitAction_win0(document.win0, '#ICClear');" tabindex='40' alt='Clear' title='Clear'> 
<a name='#ICAdvSearch' class='PSHYPERLINK' href="java script: submitAction_win0(document.win0,'#ICAdvSearch');" tabindex='41'>Basic Search</a>
<a name='#ICSaveSearch'  class='PSHYPERLINK' href="java script: submitAction_win0(document.win0,'#ICSaveSearch');" tabindex='42'><img src='/cs/fss88prd/cache/PT_SAVESEARCH_1.gif' border='0' hspace='5' align='middle' alt='' />Save Search Criteria</a>
<div id='DetachDiv' height=0 width=0 frameborder=0></div>
</form>
<a name='ICLastAnchor_win0'></a>
</body>
</html>
Link to comment
Share on other sites

Well... using that code, works just perfect for me! I copied that code in notepad and saved it as "test.html". Then I made this:

#include <IE.au3>

$oIE=_IECreate("C:\Documents and Settings\Moni\Escritorio\test.html",1)

$myProjectIDField="PROJ_SRCH_PROJECT_ID"
$myProject="000010003900"
$oQuery= _IEGetObjByName ($oIE, $myProjectIDField)
_IEFormElementSetValue ($oQuery, $myProject)

and...

Posted Image

When I use your code with the separate html file, it works. I guess that's good news!

However, I am pulling my hair out trying to figure out how to get it to work when I load the real page.

Since I am getting to that page through an intermediate page, I'm guessing that there is something else I am missing.

$oIE = _IECreate($webpage,1)

$oForm = _IEFormGetObjByName($oIE, $myForm)
$oQueryUSER = _IEFormElementGetObjByName($oForm, $myUserField)
$oQueryPWD = _IEFormElementGetObjByName($oForm, $myPWField)
_IEFormElementSetValue($oQueryUSER, $myUsername)
_IEFormElementSetValue($oQueryPWD, $myPassword)
$oSubmit = _IEGetObjByName($oIE, "submit")
_IEAction($oSubmit, "click")

;up to here is fine. I get logged in using code above. This presents me with the page containing the form I posted earlier

$myProjectIDField="PROJ_SRCH_PROJECT_ID"
$myProject="000010003900"
WinWaitActive("General") 
Sleep(2000)
;Send("{TAB 6}");if I were to use 'send', I can get the field populated
;Send($myProject)

;but if I use the next two lines, absolutely nothing happens
$oQuery= _IEGetObjByName ($oIE, $myProjectIDField)
_IEFormElementSetValue ($oQuery, $myProject)

Does the $oIE in the following line: $oQuery= _IEGetObjByName ($oIE, $myProjectIDField) need to be re-declared when a new page loads? If so, do you know how to do that?

Thanks

Link to comment
Share on other sites

_IEAction($oSubmit, "click") will not wait for the page to load completely before returning. The next action is taken ($oQuery= _IEGetObjByName ($oIE, $myProjectIDField)) when the page hasn't loaded yet (probably)

Try adding _IELoadWait($oIE) right after _IEAction($oSubmit, "click")

Just a thought...

Link to comment
Share on other sites

_IEAction($oSubmit, "click") will not wait for the page to load completely before returning. The next action is taken ($oQuery= _IEGetObjByName ($oIE, $myProjectIDField)) when the page hasn't loaded yet (probably)

Try adding _IELoadWait($oIE) right after _IEAction($oSubmit, "click")

Just a thought...

Thanks - but that's not working either. I had a similar idea, but I was using sleep to wait a few seconds.

I did notice a few warnings showing up in the SciTE debug bar:

--> IE.au3 Warning from function _IEAttach, $_IEStatus_NoMatch

--> IE.au3 Warning from function _IEGetObjByName, $_IEStatus_NoMatch

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

What do you make of the Error from function _IEFormElementSetValue statement? For fun, I changed it from a quoted string to an unquoted number. Same error message. This must be the problem.

Link to comment
Share on other sites

_IEAttach()? Must be the 1 you added in _IECreate().

I'm out of ideas to be honest, but those errors show that _IEGetObjByName isn't finding the object called "PROJ_SRCH_PROJECT_ID". Maybe the page's code changes dinamically? when you go from the first page to the second one?

Link to comment
Share on other sites

You should be paying close attention to the message output in the SciTe console -- a lot of work went into making them useful. You typically need to focus on the first error or warning you receive as they usually cascade from the root problem.

If you expect help you need to post the code that matches the messages you are getting in the console. Nothing you've posted so far uses _IEAttach.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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...