I am new to Test Framework so would appreciate a gentle introduction to working with TreeView control. I find it, do an initial click on it to expand it to it's "first level" of nodes but I then need to select the little "node arrow" next to the item in the TreeView to open up the "second level" of items in the TreeView. It's this "second click" on the little "arrow" icon next to the TreeViewItem in the TreeView control that I have to click... not sure how to do this. Any feedback is appreciated. I don't know if I have to get the *exact* x/y coordinates of that arrow next to the Item and do a User.Click(with x/y coordinates or whatever the API specifies) or if I can just set focus on a TreeViewItem and simulate the Click event on that TreeViewItem itself. Again, kinda lost so any help is appreciated.
By the way I have to write code to do this as I only have the Test Framework free edition available to me.
Thanks!
Jess
By the way I have to write code to do this as I only have the Test Framework free edition available to me.
Thanks!
Jess
6 Answers, 1 is accepted
0
Accepted
Hi Jess,
Is this a Silverlight or an HTML TreeView? The following code is for Silverlight TreeView control. It will find a TreeViewItem by its text content and will expand the node by pressing the ToggleButton.
Let me know if you require further assistance on this.
Greetings,
Plamen
the Telerik team
Is this a Silverlight or an HTML TreeView? The following code is for Silverlight TreeView control. It will find a TreeViewItem by its text content and will expand the node by pressing the ToggleButton.
SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
TreeView tree = app.Find.ByType<TreeView>();
IList<TreeViewItem> items = tree.Find.AllByType<TreeViewItem>();
foreach
(TreeViewItem item
in
items)
{
//Find an item by its text content and expand the node
if
(item.Text ==
"TextContent"
)
{
ToggleButton button = item.Find.ByType<ToggleButton>();
button.User.Click();
}
}
Let me know if you require further assistance on this.
Greetings,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Test Studio Trainings
0
Jess
Top achievements
Rank 1
answered on 21 Mar 2012, 04:23 PM
Hello,
It's a Silverlight TreeView.
Thanks for your response. I'll give it a shot.
take care,
J
It's a Silverlight TreeView.
Thanks for your response. I'll give it a shot.
take care,
J
0
Petr
Top achievements
Rank 1
answered on 03 Jan 2013, 12:02 PM
Hello Plamen,
I also have a problem with my treeview. I checked your solution and it works. However, I`d like to be able to data drive my tests and change textcontent depending on different values. So instead of "TextContent" I`d like to use a variable and data drive it. Could you please advise a solution for this?
Thank you.
Petr
I also have a problem with my treeview. I checked your solution and it works. However, I`d like to be able to data drive my tests and change textcontent depending on different values. So instead of "TextContent" I`d like to use a variable and data drive it. Could you please advise a solution for this?
Thank you.
Petr
0
Hi Petr,
Boyan Boev
the Telerik team
This is a duplicate of support ticket 646366, let's continue the discussion there.
I will update this post with the final solution.
Thank you for your cooperation.
Boyan Boev
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Test Studio Trainings
0
Humberto
Top achievements
Rank 1
answered on 18 Dec 2013, 06:47 PM
A link to the new post or forum would be nice; some of us would like to follow up to glean the new found knowledge. Please?
0
Hi Humberto,
Here is an example against our demo site:
It clicks on the toggle button "Gold" and then clicks on the "Norway" TextBlock.
Hope that helps.
Regards,
Boyan Boev
Telerik
Here is an example against our demo site:
SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
Telerik.WebAii.Controls.Xaml.RadTreeView tree = app.Find.ByType<Telerik.WebAii.Controls.Xaml.RadTreeView>();
IList<RadTreeViewItem> items = tree.Find.AllByType<RadTreeViewItem>();
foreach
(RadTreeViewItem item1
in
items)
if
(item1.Text ==
"Gold"
)
{
ToggleButton button1 = item1.Find.ByType<ToggleButton>();
button1.User.Click();
System.Threading.Thread.Sleep(2000);
item1.Refresh();
IList<TextBlock> items2 = item1.Find.AllByType<TextBlock>();
foreach
(var item
in
items2)
{
if
(item.Text==
"Norway"
)
{
item.User.Click();
}
}
}
}
It clicks on the toggle button "Gold" and then clicks on the "Norway" TextBlock.
Hope that helps.
Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Test Studio Trainings