Forum Discussion

Nformation's avatar
Nformation
Contributor
10 years ago

How do I click a grid row? Or, click a button in a cell?

I need a function that can click on the + button shown below for a given row index. So far, I've been unable to click it using the ClickCell method. I would be fine with clicking the left end of the row, but I can't find and click a row.  This is a DevExpress grid.

 

grid_button.jpg

 

The column's text is an empty string. I've tried the following...

 

 

var gridControl;
// set gridControl object
gridControl.ClickCell(index, "");

But I get the following error:

 

 

An error occurred.

Possible reasons: 

1. The application stopped responding.
2. The application was compiled incorrectly (see the Open Applications topic in the help system).
3. An error occurred in TestComplete.

Technical information:
103 0x80020006 (Unknown name.) edit.
  • Thank you all for your suggestions. I had not been looking for the WPFObjects, which is where I eventually found what I needed. Here's what I came up with.

     

     

    function clickDetailsButtonAtIndex(index)
    {
      // use when specifying the row: WPFObject("RowControl", "", index)
      index++;
     Aliases.Informa_Cashiering_Client.CurrentTransaction.ApplicationWindow.Grid.FloatingContainerBorder.Grid.FloatingContainerBody.border.Grid.PART_ContainerContent.Grid.ContentControl.ViewTransactionsView.Grid.GridControl.TableView.HierarchyPanel.WPFObject("RowControl", "", index).WPFObject("CellsControl", "", 1).WPFObject("LightweightCellEditor", "", 1).WPFObject("ButtonEdit", "", 1).Click();
    
    }

    This calls the Click() function on the button in the row specified by the index (I increment the index because I want the function to be 0-based).  Thanks again!

  • Hello Nformation,

     

    Please, record a click in the plus sign and post it here. Please, send the Object Spy of the "plus sign" and also the full Object browser hierarchy of the component.

     

    Regards,

     

    Leandro de Araújo Souza

    • Nformation's avatar
      Nformation
      Contributor

      leandroaraujoso, Thank you for the reply. 

       

      I recorded the action and converted it to script, shown below. 

       

      //Clicks the 'PART_Item' button.
       Aliases.Informa_Cashiering_Client.CurrentTransaction.ApplicationWindow.Grid.FloatingContainerBorder.Grid.FloatingContainerBody.border.Grid.PART_ContainerContent.Grid.ContentControl.ViewTransactionsView.Grid.GridControl.TableView.HierarchyPanel.RowControl.CellsControl.LightweightCellEditor.ButtonEdit.ButtonContainer.PART_Item.ClickButton();

      In addition, here is the FullName of the object in the system. 

       

      Sys.Process("Informa.Cashiering.Client").WPFObject("HwndSource: ApplicationWindow", "Informa Cashiering - aa (Location: Test Agency1 | Station: 23)").WPFObject("ApplicationWindow", "Informa Cashiering - aa (Location: Test Agency1 | Station: 23)", 1).WPFObject("Grid", "", 1).WPFObject("FloatingContainerBorder").WPFObject("Grid", "", 1).WPFObject("FloatingContainerBody").WPFObject("border").WPFObject("Grid", "", 1).WPFObject("PART_ContainerContent").WPFObject("Grid", "", 1).WPFObject("ContentControl", "", 1).WPFObject("ViewTransactionsView", "", 1).WPFObject("Grid", "", 1).WPFObject("GridControl", "", 1).WPFObject("TableView", "", 1).WPFObject("HierarchyPanel", "", 1).WPFObject("RowControl", "", 1).WPFObject("CellsControl", "", 1).WPFObject("LightweightCellEditor", "", 1).WPFObject("ButtonEdit", "", 1).WPFObject("ButtonContainer", "", 1).WPFObject("PART_Item")

      I would like a function that can click this button for a given row.

    • Nformation's avatar
      Nformation
      Contributor

      I thought I replied before, but I guess it didn't go through...

       

      I've recorded the button click and converted it to script. Below is the result.

      //Clicks the 'PART_Item' button.
      Aliases.Informa_Cashiering_Client.CurrentTransaction.ApplicationWindow.Grid.FloatingContainerBorder.Grid.FloatingContainerBody.border.Grid.PART_ContainerContent.Grid.ContentControl.ViewTransactionsView.Grid.GridControl.TableView.HierarchyPanel.RowControl.CellsControl.LightweightCellEditor.ButtonEdit.ButtonContainer.PART_Item.ClickButton();

      Below is the system FullName of the object. 

      Sys.Process("Informa.Cashiering.Client").WPFObject("HwndSource: ApplicationWindow", "Informa Cashiering - aa (Location: Test Agency1 | Station: 24)").WPFObject("ApplicationWindow", "Informa Cashiering - aa (Location: Test Agency1 | Station: 24)", 1).WPFObject("Grid", "", 1).WPFObject("FloatingContainerBorder").WPFObject("Grid", "", 1).WPFObject("FloatingContainerBody").WPFObject("border").WPFObject("Grid", "", 1).WPFObject("PART_ContainerContent").WPFObject("Grid", "", 1).WPFObject("ContentControl", "", 1).WPFObject("ViewTransactionsView", "", 1).WPFObject("Grid", "", 1).WPFObject("GridControl", "", 1).WPFObject("TableView", "", 1).WPFObject("HierarchyPanel", "", 1).WPFObject("RowControl", "", 1).WPFObject("CellsControl", "", 1).WPFObject("LightweightCellEditor", "", 1).WPFObject("ButtonEdit", "", 1).WPFObject("ButtonContainer", "", 1).WPFObject("PART_Item")

      I'd like to be able to perform this click through a function with a given row.

      • NisHera's avatar
        NisHera
        Valued Contributor

        Open your apllication and go to test compleate Object browser
        Select your object "Grid" ...something like "WPFObject("Grid",...."
        see whether it has method something like "ClickRowIndicator(row, view)"

  • sbkeenan's avatar
    sbkeenan
    Frequent Contributor

    Hi Nformation

     

    I'm not sure if this will help (I see you're using WPF controls), but do you have an 'Expand' method available.  If so, it should allow you to specify an integer value for the row number you want to expand and a boolean true/false to specify whether or not to expand the row, something like <yourCtrlReference>.Expand(2, true);  This should expand the third row (zero based) of the grid.

     

    Regards

    Stephen.

    • Nformation's avatar
      Nformation
      Contributor

      Thank you all for your suggestions. I had not been looking for the WPFObjects, which is where I eventually found what I needed. Here's what I came up with.

       

       

      function clickDetailsButtonAtIndex(index)
      {
        // use when specifying the row: WPFObject("RowControl", "", index)
        index++;
       Aliases.Informa_Cashiering_Client.CurrentTransaction.ApplicationWindow.Grid.FloatingContainerBorder.Grid.FloatingContainerBody.border.Grid.PART_ContainerContent.Grid.ContentControl.ViewTransactionsView.Grid.GridControl.TableView.HierarchyPanel.WPFObject("RowControl", "", index).WPFObject("CellsControl", "", 1).WPFObject("LightweightCellEditor", "", 1).WPFObject("ButtonEdit", "", 1).Click();
      
      }

      This calls the Click() function on the button in the row specified by the index (I increment the index because I want the function to be 0-based).  Thanks again!