_Ray Posted January 28, 2022 Share Posted January 28, 2022 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") Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted January 28, 2022 Share Posted January 28, 2022 (edited) 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 January 28, 2022 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 More sharing options...
_Ray Posted January 28, 2022 Author Share Posted January 28, 2022 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 More sharing options...
Solution Nine Posted January 28, 2022 Solution Share Posted January 28, 2022 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") _Ray 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
_Ray Posted January 30, 2022 Author Share Posted January 30, 2022 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 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