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

[Solved] The problem with finding custom controls in Silverlight application

3 Answers 55 Views
Silverlight WebAii RadControls
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Goran Tesic
Top achievements
Rank 1
Goran Tesic asked on 07 Oct 2009, 03:46 PM

Hello,

First of all I'd like to tell you your Silverlight UI testing framework looks very useful.

I'm a member of QA team in the company that I work for and I have the issues to find custom control on Silverlight page. We have DdTextBox control that is derived from System.Windows.Controls.TextBox control. On xaml page it looks like this:

<dwc:DdTextBox  x:Name="NativeUsernameField"... />

When I use this method in my test:

var username = slApp.FindName("NativeUsernameField");

I'm able to find it, but I can't assert it if it's pressed or not.

When I use this method:

DdTextBox username1 = slApp.Find.ByName<DdTextBox>("NativeUsernameField");

I have this compiler error:

Error 1 The type 'Dundas.Dashboard.Controls.DdTextBox' cannot be used as type parameter 'T' in the generic type or method 'ArtOfTest.WebAii.Silverlight.VisualFind.ByName<T>(string)'. There is no implicit reference conversion from 'Dundas.Dashboard.Controls.DdTextBox' to 'ArtOfTest.WebAii.Silverlight.FrameworkElement'. D:\Corgent Diagram\Test projects\Silverlight\SilverlightApplication10\SLTest\WebAiiVSUnitTest3.cs 163 35 SLTest

I suppose I did something wrong, but I'm not sure what. Could you, please, help me with this issue?


Thank you in advance.

Goran Tesic

3 Answers, 1 is accepted

Sort by
0
Missing User
answered on 07 Oct 2009, 05:01 PM
Hello Goran,

Thanks for the compliment, it's appreciated. If you can please try the following:

TextBox b = app.Find.ByName("NativeUsernameField").CastAs<TextBox>();     
b.Text = "My New Text"

Let us know if this works for you.

Best wishes,
Nelson Sin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Goran Tesic
Top achievements
Rank 1
answered on 07 Oct 2009, 05:32 PM
It's almost working. I have this code:

Button b = slApp.Find.ByName("NativeLoginButton").CastAs<Button>();
Assert.AreEqual("Login", b.Content);

b.User.Click();
Assert.IsTrue(b.IsPressed);

The caption on button is "Login" and first assertion is passed. Good.

But, the second assertion is failed even I forced clicking the button. I expect the second assertion to pass as well.

Do you have any idea why IsPressed property is still false?


Goran

0
Missing User
answered on 07 Oct 2009, 09:51 PM
Hello again Goran,

If you can try either a b.Refresh() or, if that doesn't work, a refresh of the visual tree via SilverlightAppReference.VisualTree.Refresh() and then check the IsPressed or IsEnabled property to see if that works for you.

Sincerely yours,
Nelson
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Silverlight WebAii RadControls
Asked by
Goran Tesic
Top achievements
Rank 1
Answers by
Missing User
Goran Tesic
Top achievements
Rank 1
Share this question
or