Jump to content

_IEFormElementOptionSelect to use wildcard


_Ray
 Share

Go to solution Solved by Nine,

Recommended Posts

Hello,

I don't know if there is already a similar question but I haven't found any. So maybe someone can help me.

I'm trying to find a value from IE dropdown but with the use of wildcard. 

For below example. I used * as wildcard just to show what I want to achieve. I am looking for the option on the red box from the screenshot using the value of 9811 only.

***Please don't mind the blue lines.

 

$oObj = _IEGetObjByName($oIE, 'j_id184:j_id193')
_IEFormElementOptionSelect($oObj, "*9811*", 1, "byText")

image.thumb.png.4d3a31b52164ff2a456f6b7fb29f7dc6.png

Link to comment
Share on other sites

Hi @_Ray,

I am not sure that I understand you completely, but did you tried [...]

_IEFormElementOptionSelect($oObj, "137680", 1, "byValue")

[...] in case the value="137680" is static/constant?
 

1 hour ago, _Ray said:

I'm trying to find a value from IE dropdown but with the use of wildcard. 

What should be the next step after you "find" it?


This is an untested and experimental alternative which probably has to be adjusted:

Func _getElementByXpath($sXPath)
    Return $oObject.document.evaluate($sXPath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null)
EndFunc

_getElementByXpath("//select/option[@value='137680']")

; or

_getElementByXpath("//select/option[contains(text(), '9811')]")

Maybe it wouldn't work, but something like this could be an option (see reference) 😅 .

Best regards
Sven

________________
Stay innovative!

Edited by SOLVE-SMART

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

Hi @SOLVE-SMART

Thanks for your input 

1 hour ago, SOLVE-SMART said:

_IEFormElementOptionSelect($oObj, "137680", 1, "byValue"

I cannot use byValue since the 9811 is from a file and. I just simplified my question. 

 

1 hour ago, SOLVE-SMART said:

Func _getElementByXpath($sXPath)     Return $oObject.document.evaluate($sXPath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null) EndFunc _getElementByXpath("//select/option[@value='137680']") ; or _getElementByXpath("//select/option[contains(text(), '9811')]")

I will take a look at this

Link to comment
Share on other sites

  • Solution

Here an example based on IE examples :

Local $bFound = False, $sSelect
  Local $oObj = _IEGetObjById($oIE, "selectExampleID")
  If Not IsObj($oObj) Then Return MsgBox($MB_SYSTEMMODAL, "", "Not an object")
  Local $colOpt = _IETagNameGetCollection($oObj, "option")
  MsgBox($MB_SYSTEMMODAL, "Number of", $colOpt.length)
  For $oOpt in $colOpt
    ConsoleWrite($oOpt.innerText & @CRLF)
    If StringInStr($oOpt.innerText, "Midi") Then
      $sSelect = StringStripWS($oOpt.innerText, $STR_STRIPTRAILING)
      _IEAction($oObj, "focus")
      _IEFormElementOptionSelect ($oObj, $sSelect, 1, "byText")
      $bFound = True
      ExitLoop
    EndIf
  Next
  If Not $bFound Then Exit MsgBox($MB_SYSTEMMODAL, "Error", "No find")

 

Link to comment
Share on other sites

On 1/28/2022 at 9:42 PM, Nine said:

Here an example based on IE examples :

Local $bFound = False, $sSelect
  Local $oObj = _IEGetObjById($oIE, "selectExampleID")
  If Not IsObj($oObj) Then Return MsgBox($MB_SYSTEMMODAL, "", "Not an object")
  Local $colOpt = _IETagNameGetCollection($oObj, "option")
  MsgBox($MB_SYSTEMMODAL, "Number of", $colOpt.length)
  For $oOpt in $colOpt
    ConsoleWrite($oOpt.innerText & @CRLF)
    If StringInStr($oOpt.innerText, "Midi") Then
      $sSelect = StringStripWS($oOpt.innerText, $STR_STRIPTRAILING)
      _IEAction($oObj, "focus")
      _IEFormElementOptionSelect ($oObj, $sSelect, 1, "byText")
      $bFound = True
      ExitLoop
    EndIf
  Next
  If Not $bFound Then Exit MsgBox($MB_SYSTEMMODAL, "Error", "No find")

 

@Nine Thank you so much!!! this is exactly what i'm looking for. you're the best!

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