Problem with getting data from a cell of a table

Class library usage, coding and language questions.
Letanir
Posts: 3
Joined: Mon Jun 26, 2017 2:16 pm

Problem with getting data from a cell of a table

Post by Letanir » Mon Jun 26, 2017 3:08 pm

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

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

Post by Support Team » Mon Jun 26, 2017 9:11 pm

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

Letanir
Posts: 3
Joined: Mon Jun 26, 2017 2:16 pm

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

Post by Letanir » Tue Jun 27, 2017 7:49 am

Hello, Ned

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

Vaughan.Douglas
Posts: 250
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

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

Post by Vaughan.Douglas » Tue Jun 27, 2017 2:53 pm

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?
Doug Vaughan

Letanir
Posts: 3
Joined: Mon Jun 26, 2017 2:16 pm

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

Post by Letanir » Wed Jun 28, 2017 10:07 am

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: [email protected]
	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.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

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

Post by krstcs » Thu Jun 29, 2017 6:26 pm

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.
Shortcuts usually aren't...

Vaughan.Douglas
Posts: 250
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

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

Post by Vaughan.Douglas » Mon Jul 03, 2017 3:31 pm

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
Doug Vaughan

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3921
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

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

Post by odklizec » Tue Jul 04, 2017 8:08 am

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? ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration