Page 1 of 1

Unable to read header text in a datagrid from code randomly

Posted: Mon Apr 30, 2018 2:21 pm
by sherinjab
Hi,

I need to read the column names of a datagrid which is dynamic and my code works sometimes but does fail a lot too. I have the correct rxpath to access these text values and it works every time I use it on Ranorex Spy, however when I debug the code to test the same Rxpath using the following code, it returns an empty list

Code: Select all

Host.Local.Find(path, duration).ToList();
Does anyone know what I can change to make this more stable?

Thanks,
Sherin

Re: Unable to read header text in a datagrid from code randomly

Posted: Mon Apr 30, 2018 2:54 pm
by odklizec
Hi,

Unfortunately, there is not much anyone here can do or suggest without seeing your app under test or at very least a Ranorex snapshot of the problematic element. Also, we need a lot of more details about the error, app under test and your testing environment.

What UI technology we are talking about?
What version of Ranorex do you use (latest is 8.1.1)?
Is there a specific need to use Find method, instead of using GetValue action associated with repository element?
Are you sure that the xpath used in Find is unique and ALWAYS points to correct element (please post a sample xpath along with ranorex snapshot...NOT screenshot).

Re: Unable to read header text in a datagrid from code randomly

Posted: Mon Apr 30, 2018 3:24 pm
by sherinjab
Hi,

We do not use Ranorex Studio but Ranorex dlls are used in our framwork to access controls based on the rxpath and using methods like FindSingle for single element and Find for a list.

Its a WPF desktop application and I'm using Ranorex 8.0. The rxpath is
/form[@wpfnative='True' and @title='Hubble [DEMO900]' and @processname='Hubble']/container/container/?/?/container[@automationid='dockPanel']/container[2]//element/container/container/container[2]/container[1]/container[@automationid='dataGridControl']/table[@automationid='dataGrid']//container[@automationid='centeringGrid']/container[@automationid='PART_ColumnHeadersPresenter']/cell/container/text

My snaphsot is more than 1MB so unable to upload it here. Please let me know how I can share it with you.

Re: Unable to read header text in a datagrid from code randomly

Posted: Mon Apr 30, 2018 3:29 pm
by odklizec
Hi,

At first, there is no snapshot attached to neither of your posts ;) At next, latest version is 8.1.1. I would strongly recommend to use this version over 8.0. There were a lot of bug fixes done between 8.0 and 8.1.1.

The xpath you posted is somewhat long and complicated and because of the use of indexes, it's pretty fragile. It may very well bet that the element is sometimes misidentified with something else with no text at all? Unfortunately, without snapshot, it's impossible to tell more.

PS: after posting my answer, I found that the snapshot is too big? So then you can use a public file sharing service (like One Drive or Drop Box) and here post a link.