This is a migrated thread and some comments may be shown as answers.

Debugging a Test - How To and TreeView question

2 Answers 98 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jess
Top achievements
Rank 1
Jess asked on 27 Mar 2012, 03:35 PM
Hello,

When I debug my tests I cannot see the value of various variables at runtime - I get a cryptic message:

"Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation."

I have this piece of code I'm testing:

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();
                }
            }

I set a break point on the if statement. I enter into debug mode, it hits my breakpoint and I hover over the item.Text but get that message described above.

The other reason I ask is that this test if failing - not sure if I need to replace the string "TextContent" with a value from the control I'm working with or if this is the actual condition I'm testing for - I took this code from another Telerik forum question on Tree controls that I have to test... so a bit unclear on that... I basically want to trigger a user selection on an element in a TreeView - "click" the "drop down arrow" next to an element in a TreeView. 


Any help on either of these two issues (or both) is appreciated.

Thanks in advance,

J

2 Answers, 1 is accepted

Sort by
0
Accepted
Anthony
Telerik team
answered on 29 Mar 2012, 10:01 PM
Hello Jess,

I researched that message and found that it's a general VS debugger problem that TS has no control over. See the MSDN forums for more information.

Yes, the "TextContent" should be replaced with the actual string you're searching for and intend to click. Here is a basic example against a Microsoft Silverlight demo site:

Manager.Settings.Web.EnableSilverlight = true;
Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
 
SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
TreeView treeView = app.Find.ByName<TreeView>("SampleSelection");
Assert.IsNotNull(treeView);
 
TreeViewItem tv5 = app.Find.ByExpression(new XamlFindExpression("XamlTag=stackpanel", "name=SampleSelectionContainer", "|", "XamlPath=/treeviewitem[0]/grid[0]/itemspresenter[name=ItemsHost]/stackpanel[0]/treeviewitem[5]")).As<TreeViewItem>();
tv5.User.Click();
 
System.Threading.Thread.Sleep(2000);
app.RefreshVisualTrees();
 
TreeView tv = app.Find.ByExpression(new XamlFindExpression("XamlTag=contentpresenter", "name=ContentTop", "|", "XamlPath=/treeviewsample[0]/stackpanel[0]/treeview[0]")).As<TreeView>();
Assert.IsNotNull(tv);
 
IList<TreeViewItem> items = tv.Find.AllByType<TreeViewItem>();
foreach (TreeViewItem item in items)
{
    if (item.TextBlockContent == "Charting")
    {
        ToggleButton button = item.Find.ByType<ToggleButton>();
        button.User.Click();
    }
}
 
System.Threading.Thread.Sleep(2000);


All the best,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Jess
Top achievements
Rank 1
answered on 29 Mar 2012, 10:02 PM
very much appreciated. 
Tags
General Discussions
Asked by
Jess
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Jess
Top achievements
Rank 1
Share this question
or