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

Testing of dynamic loaded UserControls

2 Answers 80 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Peter
Top achievements
Rank 1
Peter asked on 25 Oct 2009, 06:24 PM
Hi,

I just started to apply testing sequences for rad controls.
All works fine, but I have a question:

I'm loading UserControls dynamically in a panelbar/multipage environment. 

How do I access these dynamic objects?

Regards,
Peter 

2 Answers, 1 is accepted

Sort by
0
Missing User
answered on 26 Oct 2009, 03:13 PM
Hello Peter,

If the controls are added to the dynamically page, then you can do an ActiveBrowser.RefreshDomTree(); that will get the latest DOM. If they are added to a control that already exists, you can try a Refresh(); on the control.

You can then either try doing a Find on the ActiveBrowser or on the Control using ByContent, ById, or ByAttributes. You can also use partial strings in the Find, using "p:ByContent" or "class=~MyClass" for Atrributes or Ids.

Hope that is what you were looking for.

Kind regards,
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
Helen
Telerik team
answered on 26 Oct 2009, 04:40 PM
Hi Peter,

Find below a sample test against the Wizard example. We search for elements by Ids in it.

[TestMethod]
 
public void Wizard()
{
    Manager.LaunchNewBrowser();
 
    RadTabStrip tabStrip = Find.ById<RadTabStrip>("RadTabStrip1");
    Assert.AreEqual(true, tabStrip.AllTabs[0].Selected);
 
    HtmlInputText firstName = Find.ById<HtmlInputText>("~firstNameTextBox");
    firstName.Value = "First";
 
    HtmlInputText lastName = Find.ById<HtmlInputText>("~lastNameTextBox");
    lastName.Value = "Last";
 
    HtmlInputCheckBox agree = Find.ById<HtmlInputCheckBox>("~termsCheckBox");
    agree.Check(true, true);
 
    HtmlInputButton buttonPersonalNext = Find.ById<HtmlInputButton>("PersonaluserControl_nextButton");
    buttonPersonalNext.Click();
 
    Wait.For<RadTabStrip>(myTabStrip => myTabStrip.AllTabs[1].Selected == true, tabStrip, 10000);
 
    HtmlInputButton buttonEducationNext = Find.ById<HtmlInputButton>("EducationuserControl_nextButton");
    buttonEducationNext.Click();
 
    Wait.For<RadTabStrip>(myTabStrip => myTabStrip.AllTabs[2].Selected == true, tabStrip, 10000);
 
    HtmlInputButton buttonFinish = Find.ById<HtmlInputButton>("ProfessionaluserControl_nextButton");
    buttonFinish.Click();
 
    HtmlDiv previewWrap = Find.ByAttributes<HtmlDiv>("class=previewWrapper");
 
    HtmlSpan firstNameSpan = previewWrap.Find.ByAttributes<HtmlSpan>("id=~firstNameLabel");
 
    Wait.For<HtmlSpan>(mySpan => mySpan.TextContent == "First", firstNameSpan, 10000);
}


Hope this helps.

Kind regards,
Helen
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
General Discussions
Asked by
Peter
Top achievements
Rank 1
Answers by
Missing User
Helen
Telerik team
Share this question
or