Daymond Posted June 18, 2012 Share Posted June 18, 2012 Hi, Thanks in advance for any assistance anyone can provide. My issue should be a simple one. I am working on a front end to help me manage my affiliate accounts. On one of the affiliate sites I deal with, I come to a page with 4 forms on it. Each form has a submit button named submit. Of course if I use something like: $var = _IEFormGetObjByName($oIE, "submit") I receive the first form's submit on the page. I have attempted getting the form collection and various ways to manipulate that to attempt to get form1's submit button and must be overlooking something. I have a secondary form I am working on some error checking once the form is submitted, but am stuck on how to parse the text on the page for the following words that come up in green if the form was filled out correctly. Words in green: Submitted Successfully. Thanks again for any assistance. Link to comment Share on other sites More sharing options...
water Posted June 19, 2012 Share Posted June 19, 2012 Try $oForm = _IEFormGetCollection($oIE, 1) $var = _IEFormGetObjByName($oForm, "submit")to access the first form on your webpage. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Daymond Posted June 19, 2012 Author Share Posted June 19, 2012 (edited) Try $oForm = _IEFormGetCollection($oIE, 1) $var = _IEFormGetObjByName($oForm, "submit")to access the first form on your webpage. Ok, I have given this code a try before as well and just attempted again. However, allow me to clarify that this is actually the 4th form on the page. The first is frmlogin, the second frmrecpswd, the third 0 and the 4th form1. I used the above code but when I choose to _IEAction($var, "click") it has no effect. Here is my code: The other 2 variables are data returns from the database. $oIE = _IECreate("http://" & $affil & $dom) _IELoadWait($oIE) $oForm = _IEFormGetCollection($oIE, 4) $Submit = _IEFormGetObjByName($oForm, "submit") _IEAction($Submit, "click") Again nothing happens, the browser stops on the page with the forms. Here is the code I used to collect the form information: $oForms = _IEFormGetCollection($oIE) Local $iNumForms = @extended MsgBox(0, "Forms Info", "There are " & $iNumForms & " forms on this page") For $i = 0 To $iNumForms - 1 $oForm = _IEFormGetCollection($oIE, $i) MsgBox(0, "Form Info", $oForm.name) Next Edited June 19, 2012 by Daymond Link to comment Share on other sites More sharing options...
water Posted June 19, 2012 Share Posted June 19, 2012 I would suggest do add at least some minimal error checking: $oIE = _IECreate("http://" & $affil & $dom) ConsoleWrite(@error & @CRLF) _IELoadWait($oIE) ConsoleWrite(@error & @CRLF) $oForm = _IEFormGetCollection($oIE, 4) ConsoleWrite(@error & @CRLF) $Submit = _IEFormGetObjByName($oForm, "submit") ConsoleWrite(@error & @CRLF) _IEAction($Submit, "click") ConsoleWrite(@error & @CRLF)What do you get? Daymond 1 My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
ReFran Posted June 19, 2012 Share Posted June 19, 2012 Mmmh, you may also have a look on the form element and use something like: $oDiv = _IEFormElementGetObjByName ($oForm ,"submit") _IEAction ($oDiv,"click") HTH, Reinhard Daymond 1 Link to comment Share on other sites More sharing options...
Daymond Posted June 19, 2012 Author Share Posted June 19, 2012 I would suggest do add at least some minimal error checking: $oIE = _IECreate("http://" & $affil & $dom) ConsoleWrite(@error & @CRLF) _IELoadWait($oIE) ConsoleWrite(@error & @CRLF) $oForm = _IEFormGetCollection($oIE, 4) ConsoleWrite(@error & @CRLF) $Submit = _IEFormGetObjByName($oForm, "submit") ConsoleWrite(@error & @CRLF) _IEAction($Submit, "click") ConsoleWrite(@error & @CRLF)What do you get? I get the following: --> IE.au3 V2.4-0 Warning from function _IEFormGetCollection, $_IEStatus_NoMatch 7 --> IE.au3 V2.4-0 Error from function _IEFormGetObjByName, $_IEStatus_InvalidDataType 3 --> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType 3 Link to comment Share on other sites More sharing options...
water Posted June 19, 2012 Share Posted June 19, 2012 Seems like the instance index starts with 0. So replace $oForm = _IEFormGetCollection($oIE, 4)with$oForm = _IEFormGetCollection($oIE, 3) Daymond 1 My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Daymond Posted June 19, 2012 Author Share Posted June 19, 2012 Seems like the instance index starts with 0. So replace $oForm = _IEFormGetCollection($oIE, 4)with$oForm = _IEFormGetCollection($oIE, 3) Yeah, tried that, then 2, then 1 and even 0. I get the same results. Link to comment Share on other sites More sharing options...
water Posted June 19, 2012 Share Posted June 19, 2012 Another try. This should write the number of forms to the console as well: $oIE = _IECreate("http://" & $affil & $dom) ConsoleWrite(@error & @CRLF) _IELoadWait($oIE) ConsoleWrite(@error & @CRLF) $oForm = _IEFormGetCollection($oIE, -1) ConsoleWrite(@error & "-" & @extended & @CRLF) Daymond 1 My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Daymond Posted June 19, 2012 Author Share Posted June 19, 2012 Mmmh,you may also have a look on the form element and use something like:$oDiv = _IEFormElementGetObjByName ($oForm ,"submit")_IEAction ($oDiv,"click")HTH, ReinhardStrange, with the minimal error checking set, I receive the follwoing when I try that code:--> IE.au3 V2.4-0 Warning from function _IEFormElementGetObjByName, $_IEStatus_NoMatch7--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType30 Link to comment Share on other sites More sharing options...
Daymond Posted June 19, 2012 Author Share Posted June 19, 2012 Another try. This should write the number of forms to the console as well: $oIE = _IECreate("http://" & $affil & $dom) ConsoleWrite(@error & @CRLF) _IELoadWait($oIE) ConsoleWrite(@error & @CRLF) $oForm = _IEFormGetCollection($oIE, -1) ConsoleWrite(@error & "-" & @extended & @CRLF) i receive the following: 0 0 0 0-4 Link to comment Share on other sites More sharing options...
Daymond Posted June 19, 2012 Author Share Posted June 19, 2012 Taken from the source of the page I am working in, stripped down of course. <form id="frm1" name="form1" method="post" action="securesignup_choosecountry.asp"> <input type="hidden" Name="UserName" Value="Daymond"> <input type="submit" name="Submit" value="Continue" onclick="javascript:window.onbeforeunload = null;return checkform(event);"> </p> </form> Link to comment Share on other sites More sharing options...
DaleHohm Posted June 20, 2012 Share Posted June 20, 2012 One word. Frames. If you ConsoleWrite(_IEDocReadHTML($oIE) & @CRLF) I think you will find a frameset or one or more iframes and not your forms. You'll then need to use _IEFrameGetObjByName() and use the object returned as you would $oIE. 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...
Daymond Posted June 26, 2012 Author Share Posted June 26, 2012 One word. Frames. If you ConsoleWrite(_IEDocReadHTML($oIE) & @CRLF) I think you will find a frameset or one or more iframes and not your forms. You'll then need to use _IEFrameGetObjByName() and use the object returned as you would $oIE. Dale Thanks Dale, but as it turns out, with IE9 I was able to use the following 2 lines of code to solve the issue, but it still fails on Windows XP with IE8. $Sub = _IEGetObjByName($oIE, "form1") _IEFormSubmit($Sub) I still have a couple of other snags I need to work through and am sure I will be posting more questions. lol Thanks everyone for the assistance! 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