uteotw Posted August 10, 2006 Share Posted August 10, 2006 When a Form Element type is of "select-one" (Drop Down) how can I grab the text that is actually displayed by each option? I can get how many option items there are. I can get the value of each option. But I don't understand how the get the text associated with each. Here is the code I've written so far. $oIE = _IE_Example ("form") ;Detect each Forms $oForms = _IEFormGetCollection ($oIE) ConsoleWrite("Forms Info - There are " & @extended & " forms on this page" & @CRLF & @CRLF) For $oForm In $oForms ConsoleWrite("Form Name = " & $oForm.name & @CRLF & @CRLF) ;Detect each Forms Elements (drop downs) $oForm = _IEFormGetObjByName($oIE, $oForm.name) $oFormElements = _IEFormElementGetCollection ($oForm, -1) For $oFormElement In $oFormElements ConsoleWrite("Form Name / Element = " & $oFormElement.name & " - " & $oFormElement.type & @CRLF) If $oFormElement.type = "select-one" Then $oElementOptions = _IEFormElementGetObjByName($oForm, $oFormElement.name) ConsoleWrite("Form Name / Element / Options # = " & $oElementOptions.options.length & " items" & @CRLF) For $i = 0 to $oElementOptions.options.length-1 _IEFormElementOptionselect ($oElementOptions, $i, 1, "byIndex") _IEFormElementGetValue ($oElementOptions) ConsoleWrite(_IEFormElementGetValue ($oElementOptions)) ConsoleWrite(@CRLF) Next EndIf ConsoleWrite(@CRLF) Next ConsoleWrite(@CRLF & @CRLF) Next Any suggestions? Thanks uteotw Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted August 10, 2006 Moderators Share Posted August 10, 2006 Something like this? #include <IE.au3> $oIE = _IE_Example("form") ;Detect each Forms $oForms = _IEFormGetCollection($oIE) ConsoleWrite("Forms Info - There are " & @extended & " forms on this page" & @CRLF & @CRLF) For $oForm In $oForms ConsoleWrite("Form Name = " & $oForm.name & @CRLF & @CRLF) ;Detect each Forms Elements (drop downs) $oForm = _IEFormGetObjByName($oIE, $oForm.name) $oFormElements = _IEFormElementGetCollection($oForm) For $oFormElement In $oFormElements ConsoleWrite("Form Name / Element = " & $oFormElement.name & " - " & $oFormElement.type & @CRLF) If $oFormElement.type = "select-one" Then $oItems = $oFormElement.options For $oItem In $oItems ConsoleWrite("Form Name / Element / Options = " & $oItem.text & @CRLF) Next EndIf ConsoleWrite(@CRLF) Next ConsoleWrite(@CRLF & @CRLF) Next Link to comment Share on other sites More sharing options...
uteotw Posted August 10, 2006 Author Share Posted August 10, 2006 Super Duper. Exactly what I wanted. I think I tried something like options.text in some place but couldn't get it to work. Thanks a lot big_daddy Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted August 10, 2006 Moderators Share Posted August 10, 2006 Super Duper. Exactly what I wanted.I think I tried something like options.text in some place but couldn't get it to work.Thanks a lot big_daddyNo problem, glad I could help! Link to comment Share on other sites More sharing options...
uteotw Posted August 11, 2006 Author Share Posted August 11, 2006 Here is what I got now... Basically, it's just mimicing what IE_Builder does, but in the Console prompt, to help me work on pages with Form. expandcollapse popup#include <IE.au3> $oIE = _IE_Example("form") ;Detects each Forms $oForms = _IEFormGetCollection($oIE) ConsoleWrite("Forms Info - There are " & @extended & " forms on this page" & @CRLF & @CRLF) ;Loops through each Form For $oForm In $oForms ConsoleWrite("FormName = " & $oForm.name & @CRLF & @CRLF) ;Detect each Forms Elements $oForm = _IEFormGetObjByName($oIE, $oForm.name) $oFormElements = _IEFormElementGetCollection($oForm) ;Loops through each Form Elements For $oFormElement In $oFormElements ConsoleWrite("FormName/Element Type >> Name >> Value = " & $oFormElement.type & " >> " & $oFormElement.name & " >> " & _IEFormElementGetValue($oFormElement) & @CRLF) ;If Form Element is a Drop Down or List If $oFormElement.type = "select-one" OR $oFormElement.type = "select-multiple" Then ;Detects Form Element Options $oFormElementItems = $oFormElement.options ConsoleWrite("FormName/Element/Options Total = " & $oFormElementItems.options.length & " items" & @CRLF) For $oFormElementItem In $oFormElementItems ConsoleWrite("Form Name/Element/Options Index >> Value >> Text = " & $oFormElementItem.index & " >> " & $oFormElementItem.value & " >> " & $oFormElementItem.text & @CRLF) Next Else ;Nothing EndIf ConsoleWrite(@CRLF) Next ConsoleWrite(@CRLF & @CRLF) Next 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