I am using Silverlight automtation testing using WebAII
In my applet there is FrameworkElement Border with Tag as "news"
How can I find this element ?
I tried following but does not work. Any idea ?
manager.ActiveBrowser.NavigateTo("https://myserver.com");
SilverlightApp app = manager.ActiveBrowser.SilverlightApps()[0];
FrameworkElement my = app.Find.ByExpression(new XamlFindExpression("Tag=news"));
In my applet there is FrameworkElement Border with Tag as "news"
How can I find this element ?
I tried following but does not work. Any idea ?
manager.ActiveBrowser.NavigateTo("https://myserver.com");
SilverlightApp app = manager.ActiveBrowser.SilverlightApps()[0];
FrameworkElement my = app.Find.ByExpression(new XamlFindExpression("Tag=news"));
5 Answers, 1 is accepted
0
Hi Yogesh,
Thank you for contacting us.
Please try out with this code:
Let me know if this helps.
Regards,
Boyan Boev
Telerik
Thank you for contacting us.
Please try out with this code:
manager.ActiveBrowser.NavigateTo("https://myserver.com");
SilverlightApp app = manager.ActiveBrowser.SilverlightApps()[0];
FrameworkElement my = app.Find.ByExpression(new XamlFindExpression("XamlTag=news"));
Let me know if this helps.
Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Test Studio Trainings
0
Yogesh
Top achievements
Rank 1
answered on 03 Feb 2014, 04:43 PM
According to you
FrameworkElement my = app.Find.ByExpression(new XamlFindExpression("XamlTag=news"));
will work for finding news Framework Element for following block
<news>
<image></image>
<textblock></textblock>
</news>
What I want is to find a FrameworkElement which has Tag specified. For example, I want to find Framwork element textblock from following which has tag='johnsmith'.
<border>
<image></image>
<textblock tag='johnsmith'></textblock>
</border>
0
Hi Yogesh,
Then your code should look like:
This will find all TextBlockes (like in your case) and clicks on the first with Tag "johnsmith".
Hope that helps.
Regards,
Boyan Boev
Telerik
Then your code should look like:
IList<TextBlock> list = app.Find.AllByType<TextBlock>();
foreach
(TextBlock item
in
list)
{
if
(item.GetProperty(
new
AutomationProperty(
"Tag"
,
typeof
(
string
))).ToString()==
"johnsmith"
)
{
item.User.Click();
}
}This will find all TextBlockes (like in your case) and clicks on the first with Tag "johnsmith".
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
0
Yogesh
Top achievements
Rank 1
answered on 12 Feb 2014, 01:17 PM
Thank you very much Boyan Boev,
It worked for me. Here sharing function I have written
It worked for me. Here sharing function I have written
public
static
T FindByTag<T>(SilverlightApp app, String propertyValue) where T : FrameworkElement,
new
()
{
IList<T> list = app.Find.AllByType<T>();
T foundItem =
new
T();
foreach
(T item
in
list)
{
try
{
if
(item.GetProperty(
new
AutomationProperty(
"Tag"
,
typeof
(
string
))).ToString() == propertyValue)
{
foundItem = item;
break
;
}
}
catch
{
continue
;
}
}
return
foundItem;
}
0
Hello Yogesh,
I am really happy to hear that.
If you need further help, please let us know.
Regards,
Boyan Boev
Telerik
I am really happy to hear that.
If you need further help, please let us know.
Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Test Studio Trainings