Need help getting a specific form on webpage using IE8
#1
Posted 18 June 2012 - 10:29 PM
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.
#2
Posted 19 June 2012 - 04:27 AM
UDFs:
Active Directory (2012-10-12 - Version 1.3.0.0 released) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2012-10-07 - Version 0.9.0.0 released) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1 released) - Download - General Help & Support - Example Scripts
WordEX (2012-12-29 - Version 1.3 released) - Download
ExcelEX (2013-05-11 - Alpha 4 released) - Download
#3
Posted 19 June 2012 - 06:08 AM
Try
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 by Daymond, 19 June 2012 - 06:13 AM.
#4
Posted 19 June 2012 - 06:30 AM
$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)
- Daymond likes this
UDFs:
Active Directory (2012-10-12 - Version 1.3.0.0 released) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2012-10-07 - Version 0.9.0.0 released) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1 released) - Download - General Help & Support - Example Scripts
WordEX (2012-12-29 - Version 1.3 released) - Download
ExcelEX (2013-05-11 - Alpha 4 released) - Download
#5
Posted 19 June 2012 - 07:17 AM
you may also have a look on the form element and use something like:
$oDiv = _IEFormElementGetObjByName ($oForm ,"submit")
_IEAction ($oDiv,"click")
HTH, Reinhard
- Daymond likes this
#6
Posted 19 June 2012 - 07:20 AM
I get the following:I would suggest do add at least some minimal error checking:
What do you get?$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)
--> 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
#7
Posted 19 June 2012 - 08:00 AM
- Daymond likes this
UDFs:
Active Directory (2012-10-12 - Version 1.3.0.0 released) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2012-10-07 - Version 0.9.0.0 released) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1 released) - Download - General Help & Support - Example Scripts
WordEX (2012-12-29 - Version 1.3 released) - Download
ExcelEX (2013-05-11 - Alpha 4 released) - Download
#8
Posted 19 June 2012 - 08:25 AM
Yeah, tried that, then 2, then 1 and even 0. I get the same results.Seems like the instance index starts with 0. So replace
with
#9
Posted 19 June 2012 - 09:09 AM
$oIE = _IECreate("http://" & $affil & $dom) ConsoleWrite(@error & @CRLF) _IELoadWait($oIE) ConsoleWrite(@error & @CRLF) $oForm = _IEFormGetCollection($oIE, -1) ConsoleWrite(@error & "-" & @extended & @CRLF)
- Daymond likes this
UDFs:
Active Directory (2012-10-12 - Version 1.3.0.0 released) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2012-10-07 - Version 0.9.0.0 released) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1 released) - Download - General Help & Support - Example Scripts
WordEX (2012-12-29 - Version 1.3 released) - Download
ExcelEX (2013-05-11 - Alpha 4 released) - Download
#10
Posted 19 June 2012 - 09:30 PM
Mmmh,
you may also have a look on the form element and use something like:
$oDiv = _IEFormElementGetObjByName ($oForm ,"submit")
_IEAction ($oDiv,"click")
HTH, Reinhard
Strange, 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_NoMatch
7
--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType
3
0
#11
Posted 19 June 2012 - 09:38 PM
i receive the following: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)
0
0
0
0-4
#12
Posted 19 June 2012 - 09:50 PM
<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>
#13
Posted 20 June 2012 - 01:49 PM
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
#14
Posted 26 June 2012 - 04:40 AM
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.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
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!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users





