Jump to content

HTML drop-down list select using AutoIt


Recommended Posts

Hello Guys,

I am trying to create an AutoIt script to choose specific value (300) from an HTML drop-down list - example below:

<select name="myDropDownList" tabindex="2">
      <option value="100">100</option>   
      <option value="200">200</option>
      <option value="300">300</option>
      <option value="400">400</option>
      <option value="500">500</option>
     </select>

I tried multiple functions, but none of them seem to do what I am trying to achieve. Any help is appreciated, thanks.

 

Link to comment
Share on other sites

18 minutes ago, AutoBert said:

Have you tried _IEFormElementOptionSelect?

Yes, see below-

 

Local $oIE = "http://localhost/index.asp"
Local $oForm = _IEFormGetObjByName($oIE, "webForm")
Local $oSelect = _IEFormElementGetObjByName($oForm, "myDropDownList")
_IECreate("http://localhost/index.asp")
_IEAction($oSelect, "focus")
For $i = 1 To 10
    _IEFormElementOptionSelect($oSelect, "200", 1, "byText")
    Sleep(1000)
    _IEFormElementOptionSelect($oSelect, "300", 1, "byValue")
    Sleep(1000)
    _IEFormElementOptionSelect($oSelect, 0, 1, "byIndex")
    Sleep(1000)
Next

 

Link to comment
Share on other sites

Test this script:

Local $oIE = _IECreate("http://localhost/index.asp")
ConsoleWrite("_IECreate " & @error & @TAB & @extended & @CRLF)
Local $oForm = _IEFormGetObjByName($oIE, "webForm")
ConsoleWrite("_IEFormGetObjByName " & @error & @TAB & @extended & @CRLF)
Local $oSelect = _IEFormElementGetObjByName($oForm, "myDropDownList")
ConsoleWrite("_IEFormElementGetObjByName " & @error & @TAB & @extended & @CRLF)
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "200", 1, "byText")
ConsoleWrite("byText " & @error & @TAB & @extended & @CRLF)
Sleep(1000)
_IEFormElementOptionSelect($oSelect, "300", 1, "byValue")
ConsoleWrite("byValue " & @error & @TAB & @extended & @CRLF)
Sleep(1000)
_IEFormElementOptionSelect($oSelect, 0, 1, "byIndex")
ConsoleWrite("byIndex " & @error & @TAB & @extended & @CRLF)
Sleep(1000)

_IEQuit($oIE)

and post the output from Sciteconsole.

Link to comment
Share on other sites

On 6/25/2016 at 1:31 AM, AutoBert said:

Test this script:

Local $oIE = _IECreate("http://localhost/index.asp")
ConsoleWrite("_IECreate " & @error & @TAB & @extended & @CRLF)
Local $oForm = _IEFormGetObjByName($oIE, "webForm")
ConsoleWrite("_IEFormGetObjByName " & @error & @TAB & @extended & @CRLF)
Local $oSelect = _IEFormElementGetObjByName($oForm, "myDropDownList")
ConsoleWrite("_IEFormElementGetObjByName " & @error & @TAB & @extended & @CRLF)
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "200", 1, "byText")
ConsoleWrite("byText " & @error & @TAB & @extended & @CRLF)
Sleep(1000)
_IEFormElementOptionSelect($oSelect, "300", 1, "byValue")
ConsoleWrite("byValue " & @error & @TAB & @extended & @CRLF)
Sleep(1000)
_IEFormElementOptionSelect($oSelect, 0, 1, "byIndex")
ConsoleWrite("byIndex " & @error & @TAB & @extended & @CRLF)
Sleep(1000)

_IEQuit($oIE)

and post the output from Sciteconsole.

Thank You! It worked like a charm! 

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