Jump to content

IE _IEFormElementOptionSelect problem


Jfish
 Share

Recommended Posts

Hello all. I am at my wit's end (sadly did not take long :( ). I believe I have followed the help file and forum postings religiously but I can't get this code snippet to work. I am trying to manipulate a dropdown box on a website so that I can automate over 100 queries that would be labor intensive. The following is my code:

#include <IE.au3>

$oIE = _IECreate ("https://ourcpa.cpa.state.tx.us/taxrates/RateHist.jsp",1,1,1);create IE session, nav to rate lookup page, wait to load
$oForm = _IEFormGetObjByName ($oIE, "ratehistForm");name of form
$oSelect = _IEFormElementGetObjByName ($oForm, "spdinputname"); name of element that I want to manipulate (combobox)
;MsgBox("","",@extended)
$setResult=_IEFormElementOptionselect ($oSelect, "Blanco County So Lib Dist", 1, "byText")
MsgBox("","","result: "&$setResult&"@error: "&@error&" extended: "&@extended)

Can somebody help me understand why this is not working? The error message suggests that the first parameter is wrong. I don't know why. I used the F12 dev tool on IE to check the name of the form, name of the select control, and the text I want to set. I was able to manipulate the other parts of the form very easily where text input was required with _IEFormElementSetValue. That went so well I thought this would be a breeze ... but alas, I am stuck. Any help would be greatly appreciated.

Happy Thanksgiving.

:graduated:

JFish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

What is the error msg and on which line do you get it?

Part of the source of the page would be nice to post.

Here is the HTML from the form element I am after (complete URL in original post). If you run the code I posted you can see the complete error message in the message box. I don't get an error on a specific line - the code runs. I get an error returned from the _IEFormElementOptionselect function that suggests to me there is something wrong with the first parameter but I can't figure out why.

<BODY><BLOCKQUOTE><FORM method="post" name="ratehistForm" action="/taxrates/ratehist.do"><P>
<SELECT name="spdinputname"><OPTION>Airline Improvement Dist</OPTION><OPTION>Aldine Community Imp Dist</OPTION><OPTION>Aliana Mgmt Dist</OPTION><OPTION>Anahuac Mun Dev Dist</OPTION><OPTION>Aransas Co Health Service</OPTION><OPTION>Aransas Pass Crm Cont</OPTION><OPTION>Aransas Pass Mun Dev Dist</OPTION><OPTION>Argyle Crime Control Dist</OPTION><OPTION>Azle Crime Control Dist</OPTION><OPTION>Balcones Heights Crm Con</OPTION><OPTION>Bangs Muni Dev Dist</OPTION><OPTION>Bartonville Crm Cont</OPTION><OPTION>Baylor Co Hospital Dist</OPTION><OPTION>Baytown Crime Control</OPTION><OPTION>Baytown Crime Control District</OPTION><OPTION>Baytown Fire Con Prev Ems</OPTION><OPTION>Baytown Mun Dev Dist</OPTION><OPTION>Benbrook Library District</OPTION><OPTION>Blanco County No Lib Dist</OPTION><OPTION>Blanco County So Lib Dist</OPTION><OPTION>Blue Mound Crime Control</OPTION><OPTION>Bogata Crime Control District</OPTION><OPTION>Brewster County Esd 1</OPTION><OPTION>Brooks Co Health Services</OPTION><OPTION>Bulverde Area Lib Dist</OPTION><OPTION>Canyon Lake Library Dist</OPTION><OPTION>Castle Hills Crime Cont</OPTION><OPTION>Chambers Co Health Ser</OPTION><OPTION>Cherokee Co Dev Dist 1</OPTION><OPTION>Cibolo Can Imp Dist</OPTION><OPTION>Colleyville Crime Control</OPTION><OPTION>Comal Co ESD 6</OPTION><OPTION>Comal Co Esd 1</OPTION><OPTION>Comal Co Esd 3</OPTION><OPTION>Comal Co Esd 4</OPTION><OPTION>Comal Co Esd 5</OPTION><OPTION>Coppell Crime Control</OPTION><OPTION>Corinth Crime Control</OPTION><OPTION>Corpus Christi Crime Cont</OPTION><OPTION>Cottonwood Shores Crm Con</OPTION><OPTION>Crowley Crime Control</OPTION><OPTION>Dalworthington Gdn Cr Con</OPTION><OPTION>De Leon Hospital District</OPTION><OPTION>Delta Co Emerg Serv Dist</OPTION><OPTION>Denton Co Dev Dis 2</OPTION><OPTION>Denton County Dev Dist 4</OPTION><OPTION>Denton Co Dev Dis 5</OPTION><OPTION>Denton Co Dev Dis 7</OPTION><OPTION>Dickinson Mgmt Dist</OPTION><OPTION>Driftwood Ecd Mun Mgmt Dist</OPTION><OPTION>Dripping Springs Lib Dist</OPTION><OPTION>Duval Co Esd 1</OPTION><OPTION>E Mont Co Imp Dist</OPTION><OPTION>E Mont Co Imp Dist A</OPTION><OPTION>E Mont Co Imp Dist Edz 1</OPTION><OPTION>E Mont Co Imp Dist Edz 2</OPTION><OPTION>E Travis Gateway Lib Dist</OPTION><OPTION>Eastland Mem Hosp Dist</OPTION><OPTION>Ector Co Hospital Dist</OPTION><OPTION>El Paso Co ESD 2</OPTION><OPTION>Erath Co Dev Dist No 1</OPTION><OPTION>Euless Crime Control Dist</OPTION><OPTION>Evant Mun Dev Dist</OPTION><OPTION>Everman Crime Control</OPTION><OPTION>Flower Mound Crm Cont</OPTION><OPTION>Flower Mound Fire Cont</OPTION><OPTION>Forest Hill Crime Control</OPTION><OPTION>Forest Hill Library Dist</OPTION><OPTION>Fort Worth Crime Control</OPTION><OPTION>Fritch Crime Control</OPTION><OPTION>Goliad Mun Dev Dist</OPTION><OPTION>Grand Prairie Crime Cont</OPTION><OPTION>Grapevine Crime Control</OPTION><OPTION>Haltom City Crime Control</OPTION><OPTION>Hardin Co Esd 2</OPTION><OPTION>Harris Co Esd 10</OPTION><OPTION>Harris Co Esd 12</OPTION><OPTION>Harris Co Esd 14</OPTION><OPTION>Harris Co Esd 2</OPTION><OPTION>Harris Co Esd 21</OPTION><OPTION>Harris Co Esd 4</OPTION><OPTION>Harris Co Esd 5</OPTION><OPTION>Harris Co Esd 50</OPTION><OPTION>Harris Co Esd 6</OPTION><OPTION>Harris Co Esd 60</OPTION><OPTION>Harris Co Esd 80</OPTION><OPTION>Harris Co Imp Dist 18</OPTION><OPTION>Harris-Ft Bend Esd 100</OPTION><OPTION>Hays County Development Dist N</OPTION><OPTION>Hays Co Esd 3</OPTION><OPTION>Hays Co Esd 8</OPTION><OPTION>Hood County Dev Dist No 1</OPTION><OPTION>Hurst Crime Control Dist</OPTION><OPTION>Iowa Colony Crm Cont</OPTION><OPTION>Jasper Co Dev Dist No 1</OPTION><OPTION>Jeff Davis Co Esd 1</OPTION><OPTION>Jeff Davis Co Health Services</OPTION><OPTION>Jersey Village Crime Cont</OPTION><OPTION>Jim Hogg County Asst Dist</OPTION><OPTION>Jim Hogg Co Health Serv</OPTION><OPTION>Kaufman Co Develop Dist</OPTION><OPTION>Keller Crime Control Dist</OPTION><OPTION>Kemp Mun Dev Dist</OPTION><OPTION>Kimble Co Emerg Serv Dist</OPTION><OPTION>Kinney Co Health Services</OPTION><OPTION>La Vernia Mun Dev Dist</OPTION><OPTION>Lake Travis Library Dist</OPTION><OPTION>Lake Worth Crime Control</OPTION><OPTION>Lakewood Vil Mun Dev Dist</OPTION><OPTION>Las Damas Mgmt Dist</OPTION><OPTION>Liberty Hill Library Dist</OPTION><OPTION>Malakoff Crime Control</OPTION><OPTION>Mason Co Health Services</OPTION><OPTION>Maverick Co LFW and CDC</OPTION><OPTION>McCulloch Co Hosp Dist</OPTION><OPTION>Montgomery Co Esd 1</OPTION><OPTION>Montgomery Co ESD 12</OPTION><OPTION>Montgomery Co Esd 12-A</OPTION><OPTION>Montgomery Co Esd 3</OPTION><OPTION>Montgomery Co Esd 4</OPTION><OPTION>Montgomery Co Esd 5</OPTION><OPTION>Montgomery Co ESD 6</OPTION><OPTION>Montgomery Co ESD 7</OPTION><OPTION>Montgomery Co ESD 9</OPTION><OPTION>Morgans Pt Mun Dev Dist</OPTION><OPTION>Nacogdoches Co Hosp Dist</OPTION><OPTION>Nasa Mgmt Dist</OPTION><OPTION>No Richland Hills Crm Con</OPTION><OPTION>Old Town Spring Imp Dist</OPTION><OPTION>Orange Co Esd 3</OPTION><OPTION>Overton Mun Dev Dist</OPTION><OPTION>Ovilla Mun Dev Dist</OPTION><OPTION>Palmhurst Crime Control</OPTION><OPTION>Palmview Crime Control</OPTION><OPTION>Parker Co Dev Dis No1</OPTION><OPTION>Pasadena Crime Control</OPTION><OPTION>Pearland Mgmt Dist 1</OPTION><OPTION>Penitas Crime Cont</OPTION><OPTION>Prairie View Crime Cont</OPTION><OPTION>Reeves Co Hospital Dist</OPTION><OPTION>Reno Crime Control Dist</OPTION><OPTION>Rice Hospital District</OPTION><OPTION>Richland Hills Crime Cont</OPTION><OPTION>Richwood Crm Cont</OPTION><OPTION>River Oaks Crime Control</OPTION><OPTION>Rockdale Hospital Dist</OPTION><OPTION>Rockdale Mun Dev Dist</OPTION><OPTION>Rockdale Mun Devel Dis</OPTION><OPTION>Rockwall County Asst Dist</OPTION><OPTION>Saginaw Crime Control</OPTION><OPTION>Salado Library District</OPTION><OPTION>San Diego Mun Dev Dist</OPTION><OPTION>San Jacinto Co Esd</OPTION><OPTION>Sansom Park Crime Control</OPTION><OPTION>Schleicher Co Health Serv</OPTION><OPTION>Seabrook Crime Control</OPTION><OPTION>Selma Mun Dev Dist</OPTION><OPTION>Shavano Park Crime Control</OPTION><OPTION>Shenandoah Mun Dev Dist</OPTION><OPTION>Somervell Co Development Dist</OPTION><OPTION>South Houston Crime Cont</OPTION><OPTION>Southlake Crime Control</OPTION><OPTION>Spectrum Mgmt Dist</OPTION><OPTION>Sullivan City Crime Cont</OPTION><OPTION>The Woodlands Tnsp Edz</OPTION><OPTION>The Woodlands Township</OPTION><OPTION>Timpson Library District</OPTION><OPTION>Town Cntr Eco Dev Zone 1</OPTION><OPTION>Town Cntr Eco Dev Zone 2</OPTION><OPTION>Town Cntr Eco Dev Zone 3</OPTION><OPTION>Town Cntr Eco Dev Zone 4</OPTION><OPTION>Travis Co ESD 11</OPTION><OPTION>Travis Co Esd 11-A</OPTION><OPTION>Travis Co ESD 2</OPTION><OPTION>Travis Co ESD 3</OPTION><OPTION>Travis Co ESD 4</OPTION><OPTION>Travis Co Esd 5</OPTION><OPTION>Travis Co Esd 6</OPTION><OPTION>Travis Co Esd 6-A</OPTION><OPTION>Travis Co Esd 8</OPTION><OPTION>Uvalde Co Health Services</OPTION><OPTION>Watauga Crime Control</OPTION><OPTION>Wells Branch Library Dist</OPTION><OPTION>Westbank Library District</OPTION><OPTION>Westworth Vil Crm Con</OPTION><OPTION>White Settlement Crm Cont</OPTION><OPTION>Williamson Co Development Dist</OPTION><OPTION>Williamson Co Esd 7</OPTION><OPTION>Wimberley Village Library</OPTION><OPTION>Windcrest Crime Control</OPTION><OPTION>Winkler Co Health Service</OPTION><OPTION>Winnie-Stowell Hosp Dist</OPTION></SELECT>
</P></FORM></BLOCKQUOTE></BODY></HTML>

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

Try this one:

$oIE = _IECreate ("https://ourcpa.cpa.state.tx.us/taxrates/RateHist.jsp");create IE session, nav to rate lookup page, wait to load
$oDoc = _IEDocGetObj($oIE)
$oArray = $oDoc.getElementsByTagName ("select")
For $element In $oArray
    If $element.name == "spdinputname"  Then $setResult=_IEFormElementOptionselect ($element, "Blanco County So Lib Dist", 1, "byText")
Next
MsgBox("","","result: "&$setResult&"@error: "&@error&" extended: "&@extended)
Exit
Edited by Juvigy
Link to comment
Share on other sites

THANK YOU!!!!! You did it. I was going crazy. I appreciate your help very much. I apologize for the barrage of follow up questions but this has been a great project for me to learn about the IE functions and I just want to make sure I understand your solution.

$oIE = _IECreate ("https://ourcpa.cpa.state.tx.us/taxrates/RateHist.jsp");create IE session, nav to rate lookup page, wait to load

$oDoc = _IEDocGetObj($oIE); JFish: looks likes you are getting a reference to the document object - whereas I was trying to go after an element ID (without success in my case)

$oArray = $oDoc.getElementsByTagName ("select");JFish: I saw a reference to this in the DHTML section of MSDN when I looked it up after your post. It looks similar to "IETagNameGetCollection." Forgive my HTML ignorance but after you create a doc object can you call any DOM function thereafter with $oDoc.DomFunction?

For $element In $oArray ;JFish: this looks fairly straightforward but I would need to know that $element.name is available. Is the ".name" part of the DOM vocabulary or is that a general method to get at the name of an element in a collection object?

If $element.name == "spdinputname" Then $setResult=_IEFormElementOptionselect ($element, "Blanco County So Lib Dist", 1, "byText")

Next

MsgBox("","","result: "&$setResult&"@error: "&@error&" extended: "&@extended)

Exit

Thanks again!

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

$oDoc = _IEDocGetObj($oIE)
$oArray = $oDoc.getElementsByTagName ("select")

Is the same as :

$oArray = _IETagNameGetCollection ($oIE, "select")

(i just prefer to use it that way)

So oArray is a collection containing all the "select" objects from that page. Dont mistake it for an "array".

Each "select" object has an "name" property. Some other object collections may not have such property.

Link to comment
Share on other sites

$oDoc = _IEDocGetObj($oIE)
$oArray = $oDoc.getElementsByTagName ("select")

Is the same as :

$oArray = _IETagNameGetCollection ($oIE, "select")

(i just prefer to use it that way)

So oArray is a collection containing all the "select" objects from that page. Dont mistake it for an "array".

Each "select" object has an "name" property. Some other object collections may not have such property.

I appreciate the extra explanation. I forgot to ask one last important question ... there are several submit buttons on that page. I want to find the one I need. I think I should use _IEAction([button],"click"). I tried to use the method above. However, the button does not have a name: <input type="submit" value="Get SPD Rates"/>. How can I reference that specific button and should I use _IEAction to try to click it? Thanks again for any help you can offer.

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

It doesnt have a name but it does have a value. Just change .name to .value and it will wourk.

Thanks again. I had actually tried that but I made the noob mistake of using "submit" when I was getting the collection of objects instead of "input." It works now. I really appreciate all your help.

Regards,

Jayme

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

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