Page 1 of 1

Problem with getting data from a cell of a table

Posted: Mon Jun 26, 2017 3:08 pm
by Letanir
Hello. I have a problem and want to ask for help.
My company developes desktop application using java swing.
There are lots of tables in our application with data from database. I tryed to use Ranorex to get data from them, but it doesn't work really well. I don't get data from each cell, instead I get the whole datamodel for each cell, which is not very helpfull)
My code for getting data from cells:
foreach (var column in mR.SubscriptionsList.Grid.Table.Columns)
            {
            	foreach (var cell in column.Cells)
            	{
            		Ranorex.Report.Info(cell.Text);
            	}

            }
The way data looks in the app:
Image

Result of ranorex test (for one cell)
Image


Hope there is some solution for this problem.

Unfortunately I can't upload my snapshot, because even archived version is more than 7 MB

Re: Problem with getting data from a cell of a table

Posted: Mon Jun 26, 2017 9:11 pm
by Support Team
Hello Letanir,

Try using cell.Element.GetAttributeValueText("MyAttribute"); instead. Replace MyAttribute with the name of the attribute you wish to pull the value from.

If you continue experiencing issues, please email me your Ranorex Snapshot so I have a better understanding of your application's architecture - [email protected]. I can provide FTP info if required.

I hope this helps!

Cheers,
Ned

Re: Problem with getting data from a cell of a table

Posted: Tue Jun 27, 2017 7:49 am
by Letanir
Hello, Ned

I've tried using cell.Element.GetAttributeValueText("text");, but result was the same. I'll sent you my snapshot shortly.

Re: Problem with getting data from a cell of a table

Posted: Tue Jun 27, 2017 2:53 pm
by Vaughan.Douglas
Just out of curiosity... Can you access the cells via row objects?
foreach (var myRow in mR.SubscriptionsList.Grid.Table.rows)  
            {  
                foreach (var cell in myRow.Cells)  
                {  
                    Ranorex.Report.Info(cell.Text);  
                }  
  
            }
Also, when you're using the spy, does the appropriate value appear in the text property of the cell?

Re: Problem with getting data from a cell of a table

Posted: Wed Jun 28, 2017 10:07 am
by Letanir
It's the same with rows (I would be surprised if it would work). In spy text attribute also contains this data model (also my app throws exception when I'm using spy to "spy" on cell)

Code: Select all

java.lang.IllegalArgumentException: java.lang.ClassCastException@116a2b
	at sun.reflect.GeneratedMethodAccessor256.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.amdocs.uif.util.PublishedObjectFormatter.toUifString(PublishedObjectFormatter.java:186)
	at com.amdocs.uif.util.PublishedObjectFormatter.toUifString(PublishedObjectFormatter.java:196)
	at com.amdocs.uif.workspace.UifForm.toString(UifForm.java:4399)
	at java.lang.String.valueOf(String.java:2826)
	at java.lang.StringBuilder.append(StringBuilder.java:115)
	at java.util.AbstractMap.toString(AbstractMap.java:488)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.ranorex.UiDispatch.dispatch(UiDispatch.java:141)
	at com.ranorex.AwtUiDispatch.dispatch(AwtUiDispatch.java:59)
	at com.ranorex.UiDispatch.unsafeInvoke(UiDispatch.java:52)
	at com.ranorex.AwtUiDispatch.run(AwtUiDispatch.java:35)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642)
	at java.awt.EventQueue.access$000(EventQueue.java:85)
	at java.awt.EventQueue$1.run(EventQueue.java:603)
	at java.awt.EventQueue$1.run(EventQueue.java:601)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:612)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
I'm not really good at Java, but I've been googling a bit and it looks like all jTables have Model object inside and if you want to access data from specific cell you have to get that model first

Code: Select all

table.getModel().getValueAt(row_index, col_index);
Unfortunately it doesn't look like I'm able to access that model via Ranorex.

Re: Problem with getting data from a cell of a table

Posted: Thu Jun 29, 2017 6:26 pm
by krstcs
Ranorex is built on .NET, and is not compatible with Java, so you can't get the values by calling the Java expressions from within Ranorex.

If Ranorex Spy is not able to see the values, and Element.GetAttributeValueText doesn't work, then you may need to talk to your developers about some way to bring those values to the UI in a way that Ranorex can see. I've had to work with Java tables before and had no problem seeing the values using Ranorex, but it depends on exactly how the table is structured and what values you are trying to get.

If you can post a Ranorex Snapshot of the table along with a screen shot of the values you are trying to access it would help.

Re: Problem with getting data from a cell of a table

Posted: Mon Jul 03, 2017 3:31 pm
by Vaughan.Douglas
krstcs wrote: If you can post a Ranorex Snapshot of the table along with a screen shot of the values you are trying to access it would help.
krstcs, do you know of a way to restrict the size of a snapshot. From the original post:
Letanir wrote:Unfortunately I can't upload my snapshot, because even archived version is more than 7 MB

Re: Problem with getting data from a cell of a table

Posted: Tue Jul 04, 2017 8:08 am
by odklizec
Hi,

Here is how you can make the size of snapshot smaller...
https://www.ranorex.com/forum/a-dynamic ... tml#p38652
But this technique sometimes omits some necessary parts of GUI required for issue reproducibility.

Anyway, if the snapshot is too big for direct upload, you can always upload it to OneDrive, GoogleDrive, Dropbox or similar file sharing service and post a link here. Hope this helps? ;)