IE Dropdown Giving me fits

5 posts in this topic

#1 ·  Posted (edited)

I was working with an intranet site today and there is a huge combo box that you can click on where it says "All", underneath 'Model' (Capture.png). After selecting a model, there are numerous lines to choose from that do other things, which I can work with perfectly well. I have to deal with other pages similar to this one, but on this particular page the only "firing" event is the choice of the dropdown menu. 

Here is the source for that particular field:  (The id we care about is "cphBody_rgdModelDrawing_ctl00_ctl02_ctl02_rcbModel")

<table cellspacing="0" class="rgMasterTable" id="cphBody_rgdModelDrawing_ctl00" style="width:100%;table-layout:auto;empty-cells:show;">
        <col  />
        <col  />
        <col  />
        <col  />
        <col style="width:45px" />
        <col style="width:30px" />
            <th scope="col" class="rgHeader"><a title="Click here to sort" href="javascript:__doPostBack(&#39;ctl00$cphBody$rgdModelDrawing$ctl00$ctl02$ctl01$ctl01&#39;,&#39;&#39;)">Model</a></th><th scope="col" class="rgHeader"><a title="Click here to sort" href="javascript:__doPostBack(&#39;ctl00$cphBody$rgdModelDrawing$ctl00$ctl02$ctl01$ctl02&#39;,&#39;&#39;)">Drawing</a></th><th scope="col" class="rgHeader"><a title="Click here to sort" href="javascript:__doPostBack(&#39;ctl00$cphBody$rgdModelDrawing$ctl00$ctl02$ctl01$ctl03&#39;,&#39;&#39;)">Station Number</a></th><th scope="col" class="rgHeader"><a title="Click here to sort" href="javascript:__doPostBack(&#39;ctl00$cphBody$rgdModelDrawing$ctl00$ctl02$ctl01$ctl04&#39;,&#39;&#39;)">Sort Order</a></th><th scope="col" class="rgHeader">&nbsp;</th><th scope="col" class="rgHeader">&nbsp;</th>
        </tr><tr class="rgFilterRow">
            <td style="white-space:nowrap;">
                        <div id="cphBody_rgdModelDrawing_ctl00_ctl02_ctl02_rcbModel" class="RadComboBox RadComboBox_Default" style="width:200px;">
                <table summary="combobox" style="border-width:0;border-collapse:collapse;table-layout:fixed;width:100%">
                    <tr class="rcbReadOnly">
                        <td style="margin-top:-1px;margin-bottom:-1px;width:100%;" class="rcbInputCell rcbInputCellLeft"><input name="ctl00$cphBody$rgdModelDrawing$ctl00$ctl02$ctl02$rcbModel" type="text" class="rcbInput" id="cphBody_rgdModelDrawing_ctl00_ctl02_ctl02_rcbModel_Input" value="All" style="display: block;" readonly="readonly" /></td>
                        <td style="margin-top:-1px;margin-bottom:-1px;" class="rcbArrowCell rcbArrowCellRight"><a id="cphBody_rgdModelDrawing_ctl00_ctl02_ctl02_rcbModel_Arrow" style="overflow: hidden;display: block;position: relative;outline: none;">select</a></td>
                <div class="rcbSlide" style="z-index:6000;"><div id="cphBody_rgdModelDrawing_ctl00_ctl02_ctl02_rcbModel_DropDown" class="RadComboBoxDropDown RadComboBoxDropDown_Default " style="float:left;display:none;"><div class="rcbScroll rcbWidth" style="height:200px;width:100%;"><ul class="rcbList" style="list-style:none;margin:0;padding:0;zoom:1;"><li class="rcbItem ">All</li><li class="rcbItem ">019-208-17-3Y</li><li class="rcbItem ">019-208-17-6Y</li><li class="rcbItem ">124-ATR-3/0-L10</li><li class="rcbItem ">124-ATR-3/0-L10M</li><li class="rcbItem ">124-ATR-3/0-L10S</li><li class="rcbItem ">124-ATR-3/0-L13</li><li class="rcbItem ">124-ATR-3/0-L15</li><li class="rcbItem ">124-ATR-3/0-L15M</li><li class="rcbItem ">124-ATR-3/0-L15S</li><li class="rcbItem ">124-ATR-3/0-L18</li><li class="rcbItem ">124-ATR-3/0-L20</li><li class="rcbItem ">124-ATR-3/0-L25</li><li class="rcbItem ">124-ATR-3/0-L30</li><li class="rcbItem ">124-ATR-4/0-L10</li><li class="rcbItem ">124-ATR-4/0-L13</li>
                  .....there are thousands of these parts, listed like this. then at the end of the li tag list....
                       <script type="text/javascript">
                                function ModelIndexChanged(sender, args) {
                                    var tableView = $find("cphBody_rgdModelDrawing_ctl00");
                                    tableView.filter("ModelDrawing_ModelID", args.get_item().get_value(), "EqualTo");


I am able to read and write to the dropdown using either _IEGetFormCollection (by index because the page always has the same input indices) or _IEGetObjectById, and then using _IEFormElementSetValue. What I cannot seem to do is to use the "child" method whereby one would address the list object by using _IEFormGetCollection. That returns an error code of either 7 or 2 (it's been a long day. I forget which)

The problem with writing to the dropdown with setValue is that the form doesn't fire after you change the list box. In fact, it won't even fire if a user clicks on it, then hits return. It is only by changing the value manually and then changing it again that you can get the part number that you want to display as it should. 

How should one go about selecting the dropdown value that would allow the page to fire as it should? 



;this works but doesn't fire - I use formCollection because there are other things that I have to use fields for in this document and the indices don't change
    Local $oForm = _IEFormGetCollection($oIE, 0)
    $modelTextBox = _IEFormElementGetCollection($oForm, 7)
    _IEFormElementSetValue($modelTextBox, $chargerPartNumber)


Edited by oddlogic

Share this post

Link to post
Share on other sites

I dont see it in your html code example , but i guess there is an event which fires

function ModelIndexChanged

So after changing the value you will need to fire the event or manually execute the java function.

Share this post

Link to post
Share on other sites

Hi Juvigy!

Yes, I noticed that also but didn't see what was supposed to fire the event. I think I have a solution, though. Posting now. 

Share this post

Link to post
Share on other sites

#4 ·  Posted (edited)

For anyone interested, this was ultimately what I did to automate with consistency:


$oIE = _IECreate($modelDrawingURL)
$modelArrow = _IEGetObjById($oIE, "cphBody_rgdModelDrawing_ctl00_ctl02_ctl02_rcbModel_Arrow") ;this activates the dropdown menu - hidden 
_IEAction($modelArrow, "click")
$oForm = _IEFormGetCollection($oIE, 0)
$modelListBox = _IEFormElementGetCollection($oForm, 7)
_IEFormElementSetValue($modelListBox, $chargerPartNumber) ;this sets the part number that I want in the text box, but doesn't "fire"
ControlClick("Cleveland Drawings Admin", "", "Internet Explorer_Server1") ;I noticed that when I clicked on the window after the text value
                                                                          ;was set that IE fired. I tried clicking on the arrow again like 
                                                                          ;I did above and it didclose, but did not fire. This method closes 
                                                                          ;and fires.


Edited by oddlogic

Share this post

Link to post
Share on other sites

It should be somewhere in the html code - just open it and search for


And you should find it.

Share this post

Link to post
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

  • Similar Content

    • Spask
      By Spask
      Hi, I'm trying to find a text value inside of a html.
      This is what the line looks like normally:
      <p id="line1" class> <span class="bot">TEXT HERE</span> </p> The text then changes to a non breaking space:
      <p id="line1" class> <span class="bot">&nbsp;</span> </p> And then it changes back to normal text but it's different every time.
      Can I code this so that it grabs the text every time it changes and has a variable that represents it?
      I currently have this inside of my loop:
      $span = .document.getElementsByTagName("span") For $text In $span If $text.value = "&nbsp;" Then Sleep(50) MsgBox(0,0,0) ;messagebox to test if it can be found, but I don't know how to grab the text EndIf Next The problem is that there are many other lines in the html that have the same span but are called "line3", "line5", etc and the one I need is from "line1".
      I will appreciate if anyone can help with this!
    • electrons
      By electrons
      hi  , hope  you all doing well 
       cant find any elements on the page ?  and the right click mouse dont work too?
      iam trying with more than method , i need help please!!

    • ur
      By ur
      I have kept below line to wait for IE to load the site completely and continue.
      But, the code is continuing without waiting for it and I my execution is failing as the elements are not loaded completely.

      Any suggestions for alternate code to wait for the browser to load completely?
    • ur
      By ur
      We can select elements in IE using their IDs as below.
      Local $oDiv = _IEGetObjById($oIE, "x-auto-16-input") But to one button in the webpage, there is no ID to it.
      In selenium we have option to select this element using the CssSelector and clicked the button using below code in c# selenium.
      driver.FindElement(By.CssSelector("button.x-btn-text")).Click(); What is the alternative for this in AUtoIT?
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning everyone
      I worked a bit on a little project of mine, and I managed to do what I was trying to do, or, automate a quiz in AutoIt.
      Now, everything works fine but, in order to achieve what I'm trying to achive, I'd like to make this script run faster.
      I'll attach a portion of the code in order to let you understand what my script does.
      $objIE_h1 = _IETagNameGetCollection($objIE, "h1") ; Take the text of the answer If @error Then ConsoleWrite("Errore durante la lettura degli h1 nella pagina. - Errore: " & @error & @CRLF) Else For $objElement In $objIE_h1 $strInnerText = $objElement.innerText Next Select Case StringInStr($strInnerText, "QUESTION") ; Here is the question ; PS4 PRO $objSpans = _IETagNameGetCollection($objIE, "span") ; Answers are stored here For $objElement In $objSpans If $i >= 4 Then $strAnswer = $objElement.innerText ; Take the text of the answer n° 0, 1, 2, 3 If StringInStr($strAnswer, "CORRECT ANSWER") Then ; If I match the correct answer, then, I have to click on the input with answer id = answer_i $j = $i - 4 $objInput = _IEGetObjById($objIE, "answer_" & $j) If @error Then ConsoleWrite("Errore durante la lettura della risposta #" & $i & " - Errore: " & @error & @CRLF) Else _IEAction($objInput, "click") If @error Then ConsoleWrite("Errore durante il click sull'elemento. - Errore: " & @error) Else ConsoleWrite($j & ") Risposta: " & $strAnswer & @CRLF) ExitLoop EndIf EndIf EndIf $i+=1 Else $i+=1 EndIf Next $i = 0 $j = 0 This is what my script does.
      Questions are 20, in which I have 15 multiple choice question, 2 images ( on which I use _IEImgClick() ), and 3 text inputs ( a simple send with the text I have to enter ).
      How can I make all of these, faster?
      If I reach this goal, I've probably done one of my best goals in life, and I'd like to share my happiness with you, giving a huge donation to this fantastic community!
      Thanks for your help