shea851 Posted August 7, 2009 Share Posted August 7, 2009 (edited) Hello, I'm attempting to automate an IE webpage that seems to use javascript and is quite complex. First, I need a way to find the correct "form" on the page. $s_URL = http://www.website.com/ $o_IE = _IECreate($s_URL) $o_Form = _IEFormGetObjByName($o_IE, "formNameThatINeed!") Viewing the source or using the ie udf function "_IEDocReadHTML" isn't really helpful, since I'm looking at like over a thousand lines of code, and there doesn't appear to be any form names listed... Would using something like this work? $oIE = _IECreate (http://www.website.com/) $oForms = _IEFormGetCollection ($oIE) Or are these "forms" something different than what I would need? Thanks. Please let me know if more information is needed. Edited August 7, 2009 by shea851 Link to comment Share on other sites More sharing options...
Juvigy Posted August 7, 2009 Share Posted August 7, 2009 Check for the debugbar or the IE8 development tools they can help you greatly in your task. Link to comment Share on other sites More sharing options...
shea851 Posted August 7, 2009 Author Share Posted August 7, 2009 Check for the debugbar or the IE8 development tools they can help you greatly in your task.Checking out debugbar now.. it looks promising. Thanks a lot for the suggestion. Link to comment Share on other sites More sharing options...
shea851 Posted August 8, 2009 Author Share Posted August 8, 2009 (edited) Checking out debugbar now.. it looks promising. Thanks a lot for the suggestion. Well, I'm able to use debugbar to find the form name of anything on the page, which seems useful, except that according to Autoit, there are no forms on the page. Wtf? Just to humor myself I went ahead and ran this function: $oIE = _IECreate ("http://usd/CAisd/pdmweb.exe") $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 It tells me there are 0 forms on the page. Debugbar says otherwise. Here's my original code that doesn't work, because I can't specify a correct form. $sRequestNum = "R1234567" Func _USDtest($sRequestNum) $s_URL = ("http://usd/CAisd/pdmweb.exe") $o_IE = _IECreate($s_URL) $o_Form = _IEFormGetObjByName($o_IE, "goBtnForm") $o_RequestInputField = _IEFormElementGetObjByName($o_Form, "searchKey") _IEFormElementSetValue($o_RequestInputField, $sRequestNum) _IEFormSubmit($o_Form) SetError(0) Return 1 EndFunc And here's what Debugbar gives me for the form name: <FORM name=goBtnForm And when I run the script, here's what I get: --> IE.au3 V2.4-0 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch Am I going about this all wrong or are there just some webpages that aren't possible to automate? Because.. I'm pretty sure this should be working. Edited August 8, 2009 by shea851 Link to comment Share on other sites More sharing options...
DaleHohm Posted August 8, 2009 Share Posted August 8, 2009 You are likely being fooled by Frames or iFrames. If your form is in a frame it will not be found in the top level document and you need to use _IEFrame* functions to get a reference to the correct container. Easiest way to find frames using DebugBar is to click on the "View Source" icon on the DebugBar toolbar (blue document icon with <> over it). 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 More sharing options...
Juvigy Posted August 10, 2009 Share Posted August 10, 2009 $oIE = _IECreate ("http://usd/CAisd/pdmweb.exe") This doesnt look like a correct site address to me - what is this .exe file? Link to comment Share on other sites More sharing options...
shea851 Posted August 11, 2009 Author Share Posted August 11, 2009 $oIE = _IECreate ("http://usd/CAisd/pdmweb.exe")This doesnt look like a correct site address to me - what is this .exe file?It is. It's in a corporate environment.. that's the address to connect to the USD (Unicenter Service Desk) webpage. But I do agree that it is strange for it to show a .exe, but that's just how it is. >_< Link to comment Share on other sites More sharing options...
Juvigy Posted August 11, 2009 Share Posted August 11, 2009 And what is the address of that webpage? When you type "http://usd/CAisd/pdmweb.exe" in IE what happens? This looks like an application to me.I dont think you can use the IE functions on a .exe file. Link to comment Share on other sites More sharing options...
shea851 Posted August 11, 2009 Author Share Posted August 11, 2009 (edited) Dale.. I was being fooled by frames. The code below works perfectly for what I was trying to do. Now that I know the basics of working with the IE UDF as well as the specific webpage I hopefully shouldn't need to request further help here. Thanks everyone for your input. Inputs a request number and clicks the search button. $sRequestNum = "R1234567" _USDtest($sRequestNum) Func _USDtest($sRequestNum) $s_URL = "http://usd/CAisd/pdmweb.exe" $o_IE = _IECreate($s_URL) $o_Frame = _IEFrameGetObjByName ($o_IE, "gobtn") $o_Form = _IEFormGetObjByName($o_Frame, "goBtnForm") $o_RequestInputField = _IEFormElementGetObjByName($o_Form, "searchKey") _IEFormElementSetValue($o_RequestInputField, $sRequestNum) $o_SubmitButton = _IEGetObjByName($o_Form, "imgBtn0_button") _IEAction($o_SubmitButton, "click") SetError(0) Return 1 EndFunc Edited August 11, 2009 by shea851 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now