Forum Discussion

vaikul90's avatar
vaikul90
New Contributor
9 years ago

Unable to select row in a touchtable

Hi,

Basically, I have a touch table(a java swing based table). I need to automate the selection of a row, based on a given value (like say customer name). I am using python in test complete.

 

Test complete uses a generic click method which clicks based on (x.y) co-ordinates and is unable to do the same based on other values like name, time of entry etc. To put it more simply, I must be able to write a method which "selects customer where name is John,Doe"

 

Can anyone please help?

 

Regards

1 Reply

  • shankar_r's avatar
    shankar_r
    Community Hero

    Basically, you want to select a row based on the table column value.

     

    for this, you follow below steps:

     

    1. Loop thru rows and columns of JSwing table.

    2. When cell value matches with your expected then using the Row id you can select a particular row.

     

    This is having some basic operations with JSwing table https://support.smartbear.com/testcomplete/docs/app-objects/specific-tasks/grids/jtable/selecting-cells.html

     

    In your scenario, you want to select a row based on the customer name then you use following code.

     

    I'm not a python script-er.

     

    in Javascript,

     

    var objTable = <your swing table object>
    
    var expValue = <your expected customer name>
    
    
    for(var i = 0 ; i < objTable.wRowCount ; i++)
    
    {
    
    
         for(var j=0 ; i <objTable.wColumnCount ; j++)
    
       {
    
                  if( objTable.wValue(i,j) == expValue)
    
                 {
    
                        objTable.ClickCell(i,j);
    
                        break;
    
                  }
    
       }
    
    }

     

    //if you know column name then you use

    for(var i = 0 ; i < objTable.wRowCount ; i++)
    
    {
    
     
    
        
    
                  if( objTable.wValue(i,<your coulmn name>) == expValue)
    
                 {
    
                        objTable.ClickCell(i,<your coulmn name>);
    
                        break;
    
                  }
    
      
    
    }

    let me know if this is works for you