Issue when reading data from an Excel datasource {text:

Experiences, small talk, and other automation gossip.
IanKnight
Posts: 33
Joined: Thu Feb 21, 2013 12:52 pm

Issue when reading data from an Excel datasource {text:

Post by IanKnight » Tue Nov 04, 2014 1:15 pm

Hi,

I am running some tests using Excel as a data source, however occasionally when a data item is used the value is not the cell contents but {Text:value}

e.g.

$tst_ocs_examination = '{Text:Glucose}'

The value should simply be "Glucose"

It seems to happen fairly randomly, some times the test is executed things are fine, sometimes they fail because of this problem.

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

Re: Issue when reading data from an Excel datasource {text:

Post by krstcs » Tue Nov 04, 2014 6:08 pm

What version of Ranorex are you using?
What version of Windows are you using?
What version of Excel are you using?

Do the cells in Excel have functions in them?

Can you post the Ranorex solution here, or send it to [email protected]?
Shortcuts usually aren't...

IanKnight
Posts: 33
Joined: Thu Feb 21, 2013 12:52 pm

Re: Issue when reading data from an Excel datasource {text:

Post by IanKnight » Thu Nov 06, 2014 1:50 pm

Hi, I have got a bit further with this, and discovered it is not actually Excel that is causing the problem, it is a little bit of user code (below)

The value of tst_ocs_examination is, for example, {Text:Glucose} where it should just be "Glucose" which is why I am performing the substring manipulation to get the value I need.

Is there any way to correctly get the text value without the substring manipulation ?

Code: Select all

 var favouritesList = repo.WPF.Place_Order_Form.Select_Order_Items.Favourites_Tab.FavouritesList;
	        int itemCount = 0;

			IList<Ranorex.ListItem> listitems = favouritesList.Items;
			foreach (ListItem listitem in listitems) {
				//If not the header row then remove the favourite
				if (itemCount > 0)
				{
					listitem.Children[1].Click();
					tst_ocs_examination = listitem.Children[4].ToString();
					tst_ocs_examination = tst_ocs_examination.Substring(6,(tst_ocs_examination.Length-7));
					Report.Log(ReportLevel.Info, "User", "Removing favourite - " + tst_ocs_examination);
					repo.WPF.Generic_Messages.Sure_you_want_to_remove_x_from_favourites.Ok_button.Click();
				}
				itemCount++;
			}

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

Re: Issue when reading data from an Excel datasource {text:

Post by krstcs » Fri Nov 07, 2014 7:04 pm

For some reason my reply yesterday is gone...


I would cast the return value from ".Children[4]" to the correct element type (Text probably) and then use the ".TextValue" property.

Code: Select all

((Text)listitem.Children[1]).TextValue
"Children" returns a list of types of Unknown, which is derived from Adapter, so you should be able to cast it to the type of the actual adapter of the child and then use that adapter's properties.
Shortcuts usually aren't...