Fail to get Treeview array values
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fail to get Treeview array values
Hi,
I have problem to get values from a teeview array, I can see the array created in the debug window but i'm failing to get the actuall value fro array items.
the code line i'm using to create the array is
PatternsNumber = Aliases.CCM.BreadScrumbTree.AutomationPatternsControl.Tree.FindAll("ClrClassName", "TreeViewItem", 1) and i'm using something like PatternsNumber [0].DataContext.DisplayName to get the string name display in the UI. that doesn't get anything.
Anyone knows why?
Thanks
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have problem to get values from a teeview array, I can see the array created in the debug window but i'm failing to get the actuall value fro array items.
the code line i'm using to create the array is
PatternsNumber = Aliases.CCM.BreadScrumbTree.AutomationPatternsControl.Tree.FindAll("ClrClassName", "TreeViewItem", 1) and i'm using something like PatternsNumber [0].DataContext.DisplayName to get the string name display in the UI. that doesn't get anything.
Anyone knows why?
Thanks
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you sure that FindAll is returning a non-empty array? I'd put a breakpoint in there somewhere and inspect PatternsNumber after the FindAll call and make sure that there are contents in there. Also, what language are you writing in? Is this JScript, C++Script or C#Script? If so, note the following remarks from the documentation.
Result Value
An array of the objects that have the specified values of the specified properties. The returned collection includes the testObj object if it matches the search conditions.
Note for JScript, C#Script and C++Script users: The array returned by the FindAll
method is in the safe array format, which is not compatible with standard JScript arrays. To use such an array in JScript, C#Script or C++Script code, you need to convert it to the native format using the toArray
method of the variant array (see the examples below).
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Robert,
I'm using java script and did saw the comment you attached and did tried to use it (not sure i did it properly thou).
When the script run I did put a breakpoint exactly after the array is being created but, when looking on the variable in the watch list I can expand it and see the array items (tc says their type is string) but when trying to display one of the items for example PatternsNumber (0).Name etc. TC doesn't show any text
Can you please confirm the way i used to convert the array is correct?
please see attached
Thanks
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok I got it, i know what was my mistake and it's working now.
function Test1()
{
PatternsNumber = Aliases.CCM.BreadScrumbTree.AutomationPatternsControl.Tree.FindAll("ClrClassName", "TreeViewItem", 1)
PatternsNumber = PatternsNumber.toArray()
PatternsNumber[0].click()
}
I have another question, why if i ask him to click item[0] it click the last item in the UI?
Thanks
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If the array items are strings and not objects, then calling .Name off one of them isn't going to work. You have the "toArray" called, I'd like to see what PatternNumbers looks like AFTER toArray is applied... add toArray() to the end of your FindAll call and see what is returned.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
