Forum Discussion

chris_hunter4's avatar
chris_hunter4
New Contributor
12 years ago

Select item from drop-down in specified table row

I have an HTML table that contains drop-down lists in one of the columns. I want to select an item from the drop-down list on a specific row (the row is identified by the text contained in a different column). Because this is a table the amount of data in it can change and so the drop-down may change position and so a fixed name mapping to the drop-down is not an option.

 

I have code for clicking in a specified cell of a given table row but clicking is not enough in this case, I need to select a specific item. Is there any way of doing this?

  • I was already using 9.3 but I rolled my own solution:







    function SelectOptionInCell(table, rowIdentText, colIdx, optionName) {



    var linkCell = findCell(table, rowIdentText, colIdx);



     



    var propArray = new Array("ObjectType");



    var valArray = new Array("Select");



    var select = linkCell.FindChild(propArray, valArray, 5, true);



    if (select.Exists) {



    select.ClickItem(optionName);



    }



    else {



    Log.Error("Select element not found in cell");



    }



    }




  • Hi Chris,


     


    I see that Mike from the TestComplete Support Team replied to you:


     




    Most probably, you need to try using TestComplete 9.30, which provides more robust web object identification, to record tests. Let me quote the "Features Added to TestComplete 9.30" help topic (http://support.smartbear.com/viewarticle/51468/):


    >>>


    TestComplete now detects dynamic object ids in web applications and does not use them in the object identification criteria. Also, TestComplete can generate stable identifiers for dynamic web objects by extracting unchanging positions of their dynamic ids. You can customize dynamic identifier handling rules to make them better suit your web application under test. For more information, see Handling Dynamic Identifiers.


     


    TestComplete now generates simpler and enhanced Name Mapping for web applications by omitting certain container objects that are not directly used in tests, such as divs and tables in the web page layout. This makes your web tests more resistant to changes in the web page layout.


     


    Enhanced Name Mapping uses the Extended find setting to identify web page objects. You can switch between generating a simplified or full web object hierarchy in Name Mapping using the Use extended find when possible option in Tools  Options | Engines | Name Mapping.


    <<<