Forum Discussion

Avais's avatar
Avais
Occasional Contributor
5 years ago

Swing table - Getting the visible value from a cell not the underlying data

Hi 

 

I've run into a similar problem to the one mentioned in this discussion: 

 

https://community.smartbear.com/t5/TestComplete-Desktop-Testing/Swing-table-Getting-the-visible-value-from-a-cell-not-the/td-p/131429 

 

I'm finding it difficult to apply the solution in Python and was hoping someone could help me out.

 

Thanks

 
 
  • Hi Avais,

    The last code you posted here calls the getCellRendererComponent method:

     

     

    renderer = table.getCellRenderer(row, col).getCellRendererComponent(table, value, False, False, row, col)

     

     

    According to the article, you are referring it should be getTableCellRendererComponent. Could you please correct the code and try to execute it again. Does this help?

     

     

  • BenoitB's avatar
    BenoitB
    Community Hero

    For helping you, please show us what you have done yet in Py.

    • Avais's avatar
      Avais
      Occasional Contributor

      So I'm quite to new to Python and not sure of what library's well assist me in this. Currently the code I use to access the value of a cell is as follows 

       

      for col in range(1, len(table[row])): 
          expected_cell_value = table[row][col] # Array which extracts data from a CSv file
          actual_cell_value = get_cell_value(row,col) 
          if actual_cell_value == expected_cell_value: 
              Log.Checkpoint("Passed") 
      def get_cell_value(row,col): 
          if col == 1: 
               Value = 
      Aliases.XD.AxialImageSection.QuantScreen_panel.QuantScreen_tabbedPane.Panel.QuantScreen_table.Viewport.QuantificationTable_3.Table.wValue[1,"F"] Str = Value.ToString().OleValue; return Str
      
      • Avais's avatar
        Avais
        Occasional Contributor
        def get_cell_value(row,col):
        if col == 1:
            table  = Aliases.XD.AxialImageSection.QuantScreen_panel.QuantScreen_tabbedPane.Panel.QuantScreen_table.Viewport.QuantificationTable_3.Table
                value = Aliases.XD.AxialImageSection.QuantScreen_panel.QuantScreen_tabbedPane.Panel.QuantScreen_table.Viewport.QuantificationTable_3.Table.wValue[1,"A"]
                renderer = table.getCellRenderer(1,1).getTableCellRendererComponent(table, value, False, False, row, col)
                if aqObject.IsSupported(renderer, "getText"):
                    value = renderer.getText()
                    pass
        
                return value

        I've been playing around with it and got this bit of code which is based on the solution posted here: https://community.smartbear.com/t5/TestComplete-Desktop-Testing/getting-display-format-of-the-data-field-in-java-swing-table/m-p/130220#M7668 

        but still have not had any success with it. Upon execution of the below line, test complete looks like its doing something but I've waited 10 mins and the line of code has returned nothing to the point where I have to kill Test Complete and re launch. 

                renderer = table.getCellRenderer(1,1).getTableCellRendererComponent(table, value, False, False, row, col)