Jump to content

Having trouble with _IEFormElementOptionSelect


Coldburn
 Share

Recommended Posts

I'm wanting to ensure that my script is choosing an option that exists, otherwise do something else if it doesn't. I seem to get no errors if attempting to select an option that doesn't exist. @error always equals 0.

What am I doing wrong?

Thanks!

#include <IE.au3>
$url = http://www.example.com
$oIE = _IECreate($url, 1, 1, 1, 1)
$oParent = _IEGetObjByName($oIE, 'parent')
_IEFormElementOptionselect ($oParent, 'Bogus', 1, "byText", 0)
If @error Then
  DoBogusFunc()
Else
  DoLegitFunc()
EndIf

<select name='parent'>
<option value='1' >Genesis</option>
<option value='2' >Exodus</option>
...
</select>
Link to comment
Share on other sites

I'm working issues with this code right now.

Thanks for the reproducer -- stand-by.

Dale

P.S> in the mean time, please use byIndex or byValue

Edited by DaleHohm

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

Great thanks! I went ahead and took a look at the function knowing that you were working on it. Here's what I patched to get it working for me.

I'm using your file version T2.0-5 dated 7/3/06, on line 1579 there is an EndIf. I inserted an Else with a SetError for invalid value.

It now looks like this;

1545 - Case "byText"
1546 -   For $oItem In $oItems
1547 -     If $oItem.text = $s_string Then
  .
  .
  .
1576 -       __IEErrorNotify("Warning", "_IEFormElementOptionselect", "$_IEStatus_NoMatch", "Text not matched")
1577 -       SetError($_IEStatus_NoMatch, 2)
1578 -       Return 0
1579 -     Else    ; my additions including 1580,1581
1580 -       __IEErrorNotify("Warning", "_IEFormElementOptionselect", "$_IEStatus_NoMatch", "Text not matched")
1581 -       SetError($_IEStatus_NoMatch, 2)
1582 -     Endif

I'm not sure if lines 1576-77 need to be there or a different error specified. I know it's just a band-aid but at least it gives an error back! ;)

Thanks again!

Link to comment
Share on other sites

The real fix is actually very simple. This line

1547 -     If $oItem.text = $s_string ThenoÝ÷ Ø×vÚ!j÷JÚâîËb¢vuçZºÚ"µÍMM
ÈHYÝ[Ê   ÌÍÛÒ][K^
HH  ÌÍÜ×ÜÝ[È[

I have this in my working beta but have not yet checked it into the AutoIt beta.

Dale

Edit: BTW, the problem is that it always selects a blank entry if it exists. The simple edit above takes care of the issue.

Edited by DaleHohm

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

The real fix is actually very simple. This line

1547 -     If $oItem.text = $s_string ThenoÝ÷ Ø×vÚ!j÷JÚâîËb¢vuçZºÚ"µÍMM
ÈHYÝ[Ê   ÌÍÛÒ][K^
HH  ÌÍÜ×ÜÝ[È[

I have this in my working beta but have not yet checked it into the AutoIt beta.

Dale

Edit: BTW, the problem is that it always selects a blank entry if it exists. The simple edit above takes care of the issue.

Ha! I knew there was a problem in that IF statement somewhere! I figured you'd have the real solution. ;)

- Thanks again!

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