Forum Discussion

karenriviam's avatar
karenriviam
Occasional Contributor
2 years ago
Solved

The combo box item is out of bounds error

Hi. I have a test that keeps failing on the dropdown menus. Firstly, it selects the wrong items from the dropdown and therefore the test fails. 

I added a delay just in case and still no good. I am new on this, I have been reading a few posts here on the same subject, but nothing seems to fit this scenario. Not sure what to do. If you give me instructions, please, explain with apples and pears because as I said, I am new here. Thanks in advance.

  • Hi everybody,

     

    In the end, I managed to find a solution. I select the Key method (instead of ClickItem) and write in the details the day, month and year. It worked! Unfortunately, I closed the window where I found this solution but it was in someone else's question.

     

    Thanks for your time.

8 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    Did you get this test by recording, and when you play it back it chooses a different entry than you did originally?

    • karenriviam's avatar
      karenriviam
      Occasional Contributor

      Hi Marsha,

      Yes, I recorded, I selected a DoB (Day, Month and Year let's say 14 July 2012) and school year (Year 5) and when running the test it selected only the first items from the drop-down menu (1 January 2021 and Reception) and at the year it will stop running and prompting the errors. I did put a delay, but by doing this it still will not select the DoB I wanted but selects a few items below, like 4 of February and on the year the test will stop running, I think because it does not select anything. 

      • Marsha_R's avatar
        Marsha_R
        Champion Level 3

        What I would do is use Object Spy on the drop down and look for an index being used on the object values, so you can have something like MyDropDownMonth(0) that gives you January as a result. You may have to drill down in some of the levels using the three dots button at the far right of the ObjectSpy value.

  • Hi karenriviam.

     

    I am not sure what language you use, but this is a generic function in Jscript/Java that will walk the  wItems of a list, looking for a match, then it should set the index. It assumes the object supports the properties wItemCount, wItem, wSelectedItem, so it doesn't do any error trapping.

     

    Also, it could be expanded for other types of lists/objects that have different properties. A simple validation of which properties it supports is needed. (i.e., aqObject.IsSupported(object, property/method))

     

    Additionally, I am not sure setting the index using  wSelectedItem will work so you might need to find a Method that sets/selects the item, look in the list of Methods.

     

    The three additional functions are the calling functions for your specific controls.

     

    I hope this helps.

     

    function selectListItem(objElement, strValue)
    {
      // walk all of the items and compare to the passed value
      for (var i = 0; i < objElement.wItemCount; i++)
      {
         if (aqString.Compare(objElement.wItem(i).wText, stringValue, false) == 0)
         {
         // use the found index to select the item from the list
         objElement.wSelectedItem = i; // if this doesn't work then look for a Method that might select or set the item
         break;
         }
      }
    }

     

    function setDOBDay(strValue)
    {
      var dobDayElement = //your Code for selecting the DOB Element or the mapped object;
      selectListItem (dobDayElement, strValue);
    }

    function setDOBMonth(strValue)
    {
      var dobMonthElement = //your Code for selecting the DOB Element or the mapped object;
      selectListItem (dobMonthElement, strValue);
    }

    function setDOBYear(strValue)
    {
      var dobYearElement = //your Code for selecting the DOB Element or the mapped object;
      selectListItem (dobYearElement, strValue);
    }

  • karenriviam's avatar
    karenriviam
    Occasional Contributor

    Hi everybody,

     

    In the end, I managed to find a solution. I select the Key method (instead of ClickItem) and write in the details the day, month and year. It worked! Unfortunately, I closed the window where I found this solution but it was in someone else's question.

     

    Thanks for your time.