jmp Posted October 1, 2021 Share Posted October 1, 2021 How to select Dropdown item Using _IEFormElementOptionSelect By sometext ? Link to comment Share on other sites More sharing options...
jmp Posted October 2, 2021 Author Share Posted October 2, 2021 @Danp2 please help me. I was tried to select option from dropdown byValue & byText, it was working but i want to select option by first 2 digit number. (Not value, its Part of text) Link to comment Share on other sites More sharing options...
AlessandroAvolio Posted October 2, 2021 Share Posted October 2, 2021 18 minutes ago, jmp said: @Danp2 please help me. I was tried to select option from dropdown byValue & byText, it was working but i want to select option by first 2 digit number. (Not value, its Part of text) Hello @jmp! Can you please post your code that show how you're selecting options in dropdown menu? Thank you Link to comment Share on other sites More sharing options...
Danp2 Posted October 2, 2021 Share Posted October 2, 2021 @jmpIf you're trying to select a dropdown option by a partial string, then I don't believe that _IEFormElementOptionSelect can be used in this case. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
jmp Posted October 2, 2021 Author Share Posted October 2, 2021 59 minutes ago, Danp2 said: @jmpIf you're trying to select a dropdown option by a partial string, then I don't believe that _IEFormElementOptionSelect can be used in this case. @Danp2 Then what is used for it ? Link to comment Share on other sites More sharing options...
jmp Posted October 2, 2021 Author Share Posted October 2, 2021 3 hours ago, AlessandroAvolio said: Hello @jmp! Can you please post your code that show how you're selecting options in dropdown menu? Thank you @AlessandroAvolio I am tried with this code : #include <IE.au3> #include <MsgBoxConstants.au3> $oIE = _IEAttach ("webpage") Local $form0 = _IEGetObjById($oIE, "form2") Local $oSelect = _IEFormElementGetObjByName($form2, "SchemeID") $Division = _IEFormElementOptionSelect($oSelect, "3 : HIJ", 1, "byText") it was working but i want to select option by first 2 Character or number Like 3 HTML : <select name="NameID" class="form-Control valid" id="ddlname" style="height: 32px;" data-val-required="" data-val="true" data-val-number="The field NameID must be a number."><option selected="selected" value="0">--Select--</option> <option value="68">1 : ABC</option> <option value="1">2 : EFG</option> <option value="2">3 : HIJ</option> <option value="3">10 : LMN</option> <option value="4">6 : IPQ</option> </select> Link to comment Share on other sites More sharing options...
Solution AlessandroAvolio Posted October 2, 2021 Solution Share Posted October 2, 2021 (edited) 4 hours ago, jmp said: @Danp2 Then what is used for it ? #include <IE.au3> Main() Func Main() Local Const $sSELECT_NAME = "choice" Local Const $sPARTIAL_STRING = "third" Local $oIE, $oSelect $oIE = _IECreate("https://yari-demos.prod.mdn.mozit.cloud/en-US/docs/Web/HTML/Element/select/_sample_.Basic_select.html") $oSelect = _IEGetObjByName($oIE, $sSELECT_NAME) For $oOption In $oSelect.options If StringInStr($oOption.text, $sPARTIAL_STRING) > 0 Then Return _IEFormElementOptionSelect($oSelect, $oOption.text, 1, "byText") EndIf Next Return 0 EndFunc You need to get a list of all options of select and use Stringinstr with each of them. Use $oSelect.Option and then $oSelectOption.text like in the example upside. You also need to use a For...in..next loop in order to enumerate elements in an object collection. https://www.autoitscript.com/autoit3/docs/keywords/ForInNext.htm Edited October 2, 2021 by AlessandroAvolio 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