Childwindow automation not working

8 posts, 1 answers
  1. Kiran
    Kiran avatar
    56 posts
    Member since:
    Dec 2008

    Posted 24 Jun 2010 Link to this post

    Hi,
    Below is my test script but its not identifying the childwindow

    [TestMethod]  
            public void ChildWindowTest()  
            {  
                //  
                // TODO: Add test logic here  
                //  
                //Manager.Settings.ExecutionDelay = 10;  
     
                Manager.LaunchNewBrowser(BrowserType.InternetExplorer);  
                //System.Drawing.Point loc = ActiveBrowser.Window.Location;  
     
                ActiveBrowser.NavigateTo("http://localhost:1031/SampleSilverlightAppTestPage.aspx");  
                ActiveBrowser.WaitUntilReady();  
                SilverlightApp app = ActiveBrowser.SilverlightApps()[0];  
                Assert.IsNotNull(app);  
     
                Button btnShowConfirmDialogue = app.Find.ByName<Button>("btnShowConfirmDialogue");  
                Assert.IsNotNull(btnShowConfirmDialogue);  
                btnShowConfirmDialogue.User.Click();  
     
                Thread.Sleep(2000);  
                app.RefreshVisualTrees();  
                IList<ChildWindow> childWindows= app.Find.AllByType<ChildWindow>();  
                ChildWindow myChildWindow = app.Find.ByName<ChildWindow>("ConfirmDialogueWindow");  
     
                Button btnCancel = myChildWindow.Find.ByName<Button>("CancelButton");  
                btnCancel.User.Click();  
                  
            } 


    I have added Track method also in the Childwindow constructor

     

    public partial class ConfirmDialogue : ChildWindow  
        {  
            public ConfirmDialogue()  
            {  
                Telerik.WebUI.PopupTracker.Track(this);  
                InitializeComponent();  
            }  
     
            private void OKButton_Click(object sender, RoutedEventArgs e)  
            {  
                this.DialogResult = true;  
                MessageBox.Show("Ok");  
            }  
     
            private void CancelButton_Click(object sender, RoutedEventArgs e)  
            {  
                this.DialogResult = false;  
                MessageBox.Show("Cancel");  
            }  
        } 

     

     

     

     

     

    Below is the error i am getting
    Test method WebAiiSample.WebAiiTest.ChildWindowTest threw exception:  System.ApplicationException: Exception thrown during the wait for a condition. Error: Unexpected error while waiting on condition. Error: System.NullReferenceException: Object reference not set to an instance of an object.
       at ArtOfTest.Common.TreeCrawler`3.ByExpression(T startNode, V expression, Boolean includeRoot)
       at ArtOfTest.Common.TreeCrawler`3.ByExpression(T startNode, V expression)
       at ArtOfTest.WebAii.Silverlight.VisualWait.WaitForExistsByFindInfo(VisualFindInfo findInfo)
       at ArtOfTest.Common.WaitAsync._worker_DoWork[T,V](Object waitParam).

  2. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 25 Jun 2010 Link to this post

    Hi kiran,

    Please try the SilverlightApp.Popups collection to get to the visual tree of your ChildWindow as described in the blog post. Let us know if this approach helps.

    Best wishes,
    Konstantin Petkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Kiran
    Kiran avatar
    56 posts
    Member since:
    Dec 2008

    Posted 25 Jun 2010 Link to this post

    Hi,

    Thanks for the reply.

    i tried the below code, now i am getting timeout error
    ChildWindow cWindow = app.Popups.FirstOrDefault().VisualTree.Find.ByName<ChildWindow>("ConfirmDialogueWindow"); 

    The error is given below
    Test method WebAiiSample.WebAiiTest.ChildWindowTest threw exception:  System.TimeoutException: Wait for condition has timed out.
    ArtOfTest.Common.WaitSync.CheckResult(WaitSync wait, String extraExceptionInfo)
    ArtOfTest.Common.WaitSync.For[T](Predicate`1 predicate, T target, Boolean invertCondition, Int32 timeout)
    ArtOfTest.WebAii.Silverlight.VisualWait.ForExistsInternal(Int32 timeout, Boolean invertCondition)
    ArtOfTest.WebAii.Silverlight.VisualWait.ForVisible(Int32 timeout)
    ArtOfTest.WebAii.Silverlight.VisualFind.ReturnOrThrow(FrameworkElement e, String throwMessage)
    ArtOfTest.WebAii.Silverlight.VisualFind.ByName(String name)
    ArtOfTest.WebAii.Silverlight.VisualFind.ByName[T](String name)
    WebAiiSample.WebAiiTest.ChildWindowTest() in Z:\Kiran\VS2008\Testing\WebAiiSample\WebAiiSample\WebAiiTest.cs: line 267

  4. Answer
    Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 25 Jun 2010 Link to this post

    Hello kiran,

    The Popups contain the tracked ChildWindows visual tree. So for example if you need to click the OK button of the ChildWindow just try finding that button in the popup visual tree (instead of finding the ChildWindow and then finding that button).

    Does that work?

    All the best,
    Konstantin Petkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Kiran
    Kiran avatar
    56 posts
    Member since:
    Dec 2008

    Posted 25 Jun 2010 Link to this post

    Hi,

    you mean
    Button cancelButton = app.Popups.FirstOrDefault().VisualTree.Find.ByName<Button>("CancelButton"); 

    i tried it also, but gives the same error
  6. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 25 Jun 2010 Link to this post

    Hello kiran,

    Are you sure about the name of the button? Can you also check if the following call timeouts?

    VisualTree.Find.ByType<Button>()


    Kind regards,
    Konstantin Petkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 25 Jun 2010 Link to this post

    Hi kiran,

    Glad that worked. Sure, we will respond to your other inquires as soon as possible.

    All the best,
    Konstantin Petkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top