jmp Posted July 19, 2019 Posted July 19, 2019 How can i select random item in IE dropdown list ? Page Source : <div> <div><label id="blMember" class="control-label col-sm-push-4">select member :</label></div> <select class="form-Control" id="dlMember" name="dlMember" style="width: 190px;height:34px;"><option value="">-- Select Member --</option> <option value="3100627027001">abc</option> <option value="3100670827002">efg</option> <option value="3010627082004">hij</option> <option value="3100627827005">wxy</option> <option value="3026270827006">mno</option> </select> </div>
Danp2 Posted July 19, 2019 Posted July 19, 2019 What have you tried? Latest Webdriver UDF Release Webdriver Wiki FAQs
Nine Posted July 19, 2019 Posted July 19, 2019 Try reading all option tags value, put that in an array, use random to get a number, use array [number] “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
jmp Posted July 19, 2019 Author Posted July 19, 2019 24 minutes ago, Nine said: Try reading all option tags value, put that in an array, use random to get a number, use array [number] How to do it? i am new on autoit, please give me little example
Nine Posted July 19, 2019 Posted July 19, 2019 Look in help file, for the following statements : _IETagNameGetCollection () Random () _ArrayDisplay () Each statement is fully described with excellent examples... “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Nine Posted July 19, 2019 Posted July 19, 2019 16 minutes ago, jmp said: i am new on autoit, Really ? New ? BS ! You are on your own... “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
jmp Posted July 19, 2019 Author Posted July 19, 2019 1 hour ago, Nine said: Really ? New ? BS ! You are on your own... It was a basic script
Danp2 Posted July 19, 2019 Posted July 19, 2019 @jmp You've already been given a hint by @Nine. Read the help file, run the examples, write some code to show where you have made an attempt to solve this yourself, then come back and give us an update. Latest Webdriver UDF Release Webdriver Wiki FAQs
jdelaney Posted July 19, 2019 Posted July 19, 2019 get the count of options, _IEFormElementOptionSelect with mode = byIndex...use Random() to set the integer IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
jmp Posted July 25, 2019 Author Posted July 25, 2019 (edited) @Nine, I am tried reading all option tags value using : $idlMember = _IEGetObjById($oIE, "dlMember") $TXT = "" $items = $idlMember.options For $item in $items $TXT = $TXT & $item.value & @CRLF Next MsgBox(0, "", $TXT) it was getting all option, How can i select randomly one option from these? Edited July 25, 2019 by jmp
jmp Posted July 25, 2019 Author Posted July 25, 2019 On 7/20/2019 at 5:03 AM, jdelaney said: get the count of options, _IEFormElementOptionSelect with mode = byIndex...use Random() to set the integer Thanks @jdelaney, But It was select sometimes, Most of times it get error in line. My code is : Local $oForm = _IEFormGetObjByName($oIE, "selectdldl") Local $oSelect = _IEFormElementGetObjByName($oForm, "dlMember") $iOptionCount = $oSelect.length $nOption = Random(1, $iOptionCount) _IEFormElementOptionSelect($oSelect, $nOption, 1, "byIndex")
jdelaney Posted July 25, 2019 Posted July 25, 2019 Possibly because you don't have the flag set on random to return an integer. it's the third parameter. Do a consoleoutput of $noption to debug. otherwise you need to add debugging into the ie function to see what's going wrong IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
jdelaney Posted July 25, 2019 Posted July 25, 2019 Oh, byindex is 0 based. set random to 0, count-1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
jmp Posted July 25, 2019 Author Posted July 25, 2019 10 minutes ago, jdelaney said: Possibly because you don't have the flag set on random to return an integer. it's the third parameter. Do a consoleoutput of $noption to debug. otherwise you need to add debugging into the ie function to see what's going wrong How can i do these?
jmp Posted July 25, 2019 Author Posted July 25, 2019 9 minutes ago, jdelaney said: Oh, byindex is 0 based. set random to 0, count-1 @jdelaney I want to skip first option from selection.
jdelaney Posted July 25, 2019 Posted July 25, 2019 (edited) You still must update the second param to $ioptioncount-1 Edited July 25, 2019 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
jmp Posted July 26, 2019 Author Posted July 26, 2019 (edited) 9 hours ago, jdelaney said: You still must update the second param to $ioptioncount-1 Like this? Local $oForm = _IEFormGetObjByName($oIE, "selectdldl") Local $oSelect = _IEFormElementGetObjByName($oForm, "dlMember") $iOptionCount = $oSelect.length $nOption = Random(1, $iOptionCount-1) _IEFormElementOptionSelect($oSelect, $nOption, 1, "byIndex") Edited July 26, 2019 by jmp
jdelaney Posted July 27, 2019 Posted July 27, 2019 (edited) looks good. Are you actually getting the count of the items from your $oSelect.length? You might need to get the child nodes count. ConsoleOutput($iOptionCount & @crlf) to check. Edited July 27, 2019 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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