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

Childwindow automation not working

7 Answers 145 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kiran
Top achievements
Rank 2
Kiran asked on 24 Jun 2010, 08:38 PM
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).

7 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 25 Jun 2010, 08:13 AM
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
0
Kiran
Top achievements
Rank 2
answered on 25 Jun 2010, 09:43 AM
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

0
Accepted
Konstantin Petkov
Telerik team
answered on 25 Jun 2010, 09:50 AM
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
0
Kiran
Top achievements
Rank 2
answered on 25 Jun 2010, 09:57 AM
Hi,

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

i tried it also, but gives the same error
0
Konstantin Petkov
Telerik team
answered on 25 Jun 2010, 10:11 AM
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
0
Kiran
Top achievements
Rank 2
answered on 25 Jun 2010, 10:34 AM
0
Konstantin Petkov
Telerik team
answered on 25 Jun 2010, 11:25 AM
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
Tags
General Discussions
Asked by
Kiran
Top achievements
Rank 2
Answers by
Konstantin Petkov
Telerik team
Kiran
Top achievements
Rank 2
Share this question
or