Forum Discussion

AKarandjeff's avatar
AKarandjeff
Contributor
14 years ago

DataGrid ItemRender ID keeps changing

I am attempting to take a checkpoint to do a caption validation within a data grid.  However I am running into problems with the validation because the DataGridItemRenderer ID keeps changing on me.  Sometimes it will show up as 19, sometimes it's 59 as outlined below, though I'm not sure if it's just those two values.  I've been reading through the documentation, and have not been able to find a definitive way to map this particular cell so it gets identified properly each time.  Any thoughts? Below is an example of what Object Spy grabs.  The last value in (), 59 in this example, is what's changing on me.  I looked at the Object Properties in the Object Browser and have tried refreshing multiple times in search of a common property and cannot see anything unique to identify the cell, unless I'm missing something.  Thanks.



Sys.Process("iexplore").Page("http://localhost:9663/Ventraq/").Object("C3CSelfCare").C3CEUI("C3CSelfCare").Group(0).Group("contentGroup").VGroup(0).ModuleLoader("MainNavigator").MainNavigator(0).Group("contentGroup").Group("mainView").TabNavigator("mainStack").ModuleLoader("My Phone Book").PhoneBookModule(0).Group("contentGroup").Panel("My Phone Book").Group(0).Group("contents").Group("contentGroup").PhoneBook("PhoneBook").VGroup("phoneBookContent").DataGrid("entries").ListBaseContentHolder(0).DataGridItemRenderer(59)
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Andrew,



    To verify a value in a grid cell, create a property checkpoint for the wValue(row, column) property of the grid object. See the attached images.



    As for DataGridItemRenderer objects, they are internal helper objects used to render the grid contents, that's why, they have dynamic indexes. They aren't supposed to be used for automation; you need to use methods and properties of the grid object (FlexDataGrid) instead.
  • Thanks Helen, that worked.  I had read through a good chunk of the Flex documentation, but could not figure out from said documentation how to get it to work.  It might be worth something to put a blurb in the documentation on data grids about cell addressing vs. what Flex renders internally.  I knew there had to be an absolute somewhere, just couldn't figure out where.  Thanks!!
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Glad to help, Andrew! Please feel free to ask any further questions you may have.



    And thanks for the feedback on the Flex testing docs. We'll see what we can do to improve them.
  • Watch what you offer, as I'll take you up on it :) I've got another situation involving data grids and I'm sure it's a similar solution, but I'm not quite sure how to get there.  I have a situation where I've got an AdvancedDataGrid object where I need to find a specific labelField value in one column (picture 1 in attachment) and then click on the adjoining checkbox in the next column (picture 2).  This grid is not ordered, so the value I'm looking for "Only take calls from people on my list" in the label field could potentially be anywhere.  Clicking the checkbox will pop a sub-list and I then need to do a couple of property checkpoints to verify that they're disabled (picture 3 along with checkpoint code from script conversion of visual recording).  Is this even possible?  Thanks.
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Andrew,



    The situation with AdvancedDataGrid here is similar to the one with DataGrid. To work with grid elements, it is recommended that you target the grid object itself -- AdvancedDataGrid("stationGrid") -- rather than the element renderers (AdvancedListBaseContentHolder, etc).



    Unfortunately, TestComplete doesn't provide any extended methods and properties for automating Flex AdvancedDataGrid like it does for DataGrid, but you might be able to perform the needed actions with the grid's native methods and properties. You can access these native methods and properties in the Object Spy and your tests via the grid's FlexObject property. To see an example of the native methods' use in tests, check out the Work with AdvancedDataGrid sample script.



    For example, to find a grid row by the cell value, you can iterate through the grid's rows (which should be accessible via AdvancedDataGrid("stationGrid").dataProvider.source.item(rowIndex)) and check the values in the appropriate data field. I'm afraid, I can't come up with a concrete detailed algorithm and script code for your entire task, because your grid seems to be customized, but I hope you get the idea.



    BTW, you can submit a feature request for the extended AdvancedDataGrid support here, and if it gets enough votes, the TestComplete team will consider adding it to the roadmap for future versions.