cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted
Occasional Contributor

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-valu... 

 

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

 

Thanks

 
 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Manager

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

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?

 

 

---------
Tanya Gorbunova
SmartBear Community Manager

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today

View solution in original post

8 REPLIES 8
Highlighted
Community Leader

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

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

Un sourire et ça repart

Highlighted
Occasional Contributor

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

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
Highlighted
Occasional Contributor

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

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-f... 

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)
Highlighted
Community Leader

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

I don't have under hand a swing table to test.

What is strange is the long delay of the rendered.

Perhaps due to Aliases ? Try again with real acces to object avoiding Aliases.

 

 

Un sourire et ça repart

Highlighted
Occasional Contributor

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

When you say 'with real access to objects' do you mean the following? 

 

def get_cell_value(row, col):
    table = Sys.Process("XD").SwingObject("JFrame", "Synthetic - Bilada BD - bilada BD", 0).SwingObject("JRootPane", "", 0).SwingObject("null.layeredPane").SwingObject("null.contentPane").SwingObject("JPanel", "", 0).SwingObject("QuantScreen-panel").SwingObject("QuantScreen-tabbedPane").SwingObject("JPanel", "", 5).SwingObject("QuantScreen-table").SwingObject("JViewport", "", 0).SwingObject("QuantificationTable$3", "", 0).SwingObject("JTable", "", 0)
    value = table.getValueAt(row, col)
    renderer = table.getCellRenderer(row, col).getCellRendererComponent(table, value, False, False, row, col)
    if aqObject.IsSupported(renderer, "getText"):
        value = renderer.getText()
    return str(value)

 

 

Highlighted
Community Leader

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

Yep, still same issue ?

Un sourire et ça repart

Highlighted
Occasional Contributor

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

I'm getting a Python runtime error: The object does not support this property or method.

Highlighted
Community Manager

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

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?

 

 

---------
Tanya Gorbunova
SmartBear Community Manager

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!

Retrieve Data from a Web Page

Participate!