Page 1 of 1

Issue when reading data from an Excel datasource {text:

Posted: Tue Nov 04, 2014 1:15 pm
by IanKnight
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.

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

Posted: Tue Nov 04, 2014 6:08 pm
by krstcs
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]?

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

Posted: Thu Nov 06, 2014 1:50 pm
by IanKnight
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++;
			}

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

Posted: Fri Nov 07, 2014 7:04 pm
by krstcs
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.