Forum Discussion

juliocesar_nec's avatar
juliocesar_nec
New Contributor
8 years ago

Two clicks on a name on the grid

Hello, I have a grid in my system that I need to do a search and it will search on this grid.

 

I want the testComplete to select the row in the grid that has a word the same or similar to the one searched.

 

How to make?

 

The record script gave me this line of code:

 Aliases.SCOM_sac.frmPsqCities_IBGE.pnlGridPesq.cxGridPsq.DblClickCell (7, 'City', 0);

 

But in that case, he's selected a specific place and I want him to pick up the name.

3 Replies

  • Grids are tricky. My framework gets pretty complicated but abstracts the difficulty out of grids. In short there's no super quick answer.

     

    Grids are tricky because of scrolls. You must make sure your row is even in view. 

     

    In high level your automation could maybe do something like: 

    1) Ask for a ctrl-F function inside the grid so you can do a search inside the grid to get to your row.

    2) Do a Find for the row that is highlighted. (There should be a property that defines that its highlighted). 

    3) Assign an object to the result of that find.

    4) Do an object.DblClick() 

  • Marsha_R's avatar
    Marsha_R
    Icon for Champion Level 3 rankChampion Level 3

    The results of your recording still gives you a clue.  If you want "Name" instead of  "City", then loop on whichever one of those numbers is the row and check for "Name" = your desired value.  Be sure and have a way out if the whole grid is checked and the name is not found.

  • csnider's avatar
    csnider
    Occasional Contributor

    I am hitting a Telerik grid.  I'm not a programmer and it took me a while to figure this out, but the FindRow, DblClickRowIndicator, and LastResult worked for me.

     

    Maybe something similar would work for you?  Can be done using the Keyword GUI as well.

     

    function Test2()
    {
      var LastResult;
      LastResult = Aliases.BetaGlobalDataEntry.GlobalDataEntryMainForm.radDock1.toolTabStrip5.twBatches.radSplitContainer1.splitPanel2.gvBatches.FindRow("ID", KeywordTests.Test2.Variables.oceanPositive("batchID"));
      Aliases.BetaGlobalDataEntry.GlobalDataEntryMainForm.radDock1.toolTabStrip5.twBatches.radSplitContainer1.splitPanel2.gvBatches.DblClickRowIndicator(LastResult);
    }