Hi All,
There is an ilist we are using to hold list of Text objects we want from a table.
Getting them is not an issue but keeping them in the IList is a problem.
See the code below,
IList<Text> ilColumnList = new List<Text>();
IList<Element> ilElements = tblPriorityField().Find("element");
int intColIndex = (penumPriorityField == PriorityField.Values) ? 1 : 2;
foreach (Element eleTemp in ilElements)
{
if (!eleTemp.Visible) eleTemp.EnsureVisible();
ilColumnList.Add(eleTemp.FindSingle("element[" + intColIndex + "]/text"));
}
So, as you can see the IList has a clause that it take Text objects that are visible. Because the table has hidden rows and we cant see the text objects under the element unless they are visible. When it comes to adding the text that was just made visible the 'add' operation is going and replacing the one that has gone invisible because of the scroll operation to make present text object visible.
Example:
IList has these objects for now,
Object1
Object2
Object3
Object4
The other objects are invisible,
Object5
Object6
So, when we make Object5 visible then add it, its replacing the Object1 which has gone invisible now. Like this,
Object5
Object2
Object3
Object4
Now, we know that IList is holding the references and not the copies of the Text objects!
We solved it my taking out the Text values from those texts which were what we wanted.
Text txtTemp = eleTemp.FindSingle("element[" + intColIndex + "]/text");
ilColumnList.Add(txtTemp.TextValue);
Off course with changes made to IList type and all the jazz needed.
My question is why IList is holding the references?
IList items are getting replaced
- testautomator
- Posts: 67
- Joined: Fri Oct 25, 2013 6:37 am
- Location: Bangalore, India
- testautomator
- Posts: 67
- Joined: Fri Oct 25, 2013 6:37 am
- Location: Bangalore, India
Re: IList items are getting replaced
Can anybody please reply? 

Re: IList items are getting replaced
Hello,
Text is a "Reference Type", not a "Value Type": http://msdn.microsoft.com/en-us/library/t63sy5hs.aspx
Text is a "Reference Type", not a "Value Type": http://msdn.microsoft.com/en-us/library/t63sy5hs.aspx
SW
- testautomator
- Posts: 67
- Joined: Fri Oct 25, 2013 6:37 am
- Location: Bangalore, India
Re: IList items are getting replaced
@swmatisa : Thanks for that info