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

Creating easily modifiable automated tests for RadTabControl

1 Answer 100 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Melinda
Top achievements
Rank 1
Melinda asked on 19 Jun 2012, 07:47 PM
Hi,

I've gotten pretty familiar with how to use Telerik Test Studio to automate Silverlight controls, but I'm struggling with how to make the test steps more dynamic.

For example, I have a RadTabControl that has tabs that might vary. I'm trying to figure out a way to automate which tab I click on, but the tab might be in a different spot and I'm not sure if it will always have the same value for AutomationId or XamlTag. I'd really like a way to create a test that will click on a tab depending on the text on that tab, but I haven't been able to figure out how to do that by editing the elements created by Test Studio.

Is there an easy way to automate a test but have the step where the test clicks on a tab item be variable depending on the text we're looking for on the tab itself? Even if I have to edit the text for the tab in Test Studio before I run it, I'd like a way to change which text I'm looking for on the tab.

I'm also going to be looking to do this with iterating through rows in a grid view, but for now I'm starting with the tabs.

Thanks in advance for the help!

1 Answer, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 22 Jun 2012, 08:42 PM
Hello Melinda,

Due to the complexity of a Silverlight visual tree, the TabItem itself is rarely the element that directly contains the text. In most cases, it contains a child TextBlock that holds the text. I tested against this Telerik Silverlight RadTabControl demo page and by default, a TabItem's TextBlock (see screen shot 1) was found by its TextContent (see screen shot 2). So you can explicitly choose the TextBlock to record the click against.

Currently you cannot data drive find expressions through the UI, but this can be accomplished in code by referencing a data column:

SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
 
TextBlock tb = app.Find.ByTextContent(Data["Col1"].ToString()).As<TextBlock>();
RadTabItem rti = tb.Parent<RadTabItem>();
rti.User.Click();

If you prefer Visual Basic, use our code converter.

All the best,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Melinda
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Share this question
or