Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Automated Testing and WebUI Test Studio > Telerik Testing Framework > My test has stopped opening a new pop up window.
These forums are read-only and serve as an archive for the previous versions of WebUI Test Studio.
For the current forums please go to the Automated Testing and WebUI Test Studio Forums

Answered My test has stopped opening a new pop up window.

Feed from this thread
  • pearl oguchi avatar

    Posted on May 28, 2010 (permalink)

    Hello. I have a major problem here and have exhausted all avenues to a solution. I am not a developer so I am somewhat rubbish with code. However, I am starting to grasp writing unit tests, though i have a very long way to go.

    I am trying to write a unit test to use to run a load test. This test consists of a user logging into their account, then clicking an item on a list, which then opens a popup window (not modal pop up, just another browser window). Now there are two problems to this.

    1. When i run the test, when it gets to the point where the user clicks the button to open another window, nothing happens. Before, when i ran the test, you could see the mouse pointer clicking the button, then a new window actually opened. Then all of a sudden, it stopped working. The funny thing is that when i run the test now, even though the window doesn't open, the test passes. My question is, why has the window stopped opening? I need to continue the test on this new window and if it doesn't open, the rest of the test fails. I did something differently prior to this problem starting. I changed my IE8 tab settings for pop ups to open in a new window, instead of a tab. This worked for a while, then it just stopped working and no longer opens a new window.

    2. At the time the test was working and opened a new window, I tried to continue to run the test but it kept failing (even thugh the editor doesn't complain with the code and there are no build errors) with the message: "System.NullReferenceException: Object reference not set to an instance of an object." Now from what i understand, this means that the object was not found. The aim of the line that thre the test was for the user to click an object in the new pop up window. The window was open, the object is visible in the window. The only conclusion i can come up with is that the test is still looking at the old window and not the new pop up window. My question then is that how do i attach my unit test to a new popup window that opens within the test.

    Just to be clearer, this is the code. I hope it throws some light to the situation:

     

    Thanks for any help.

     

    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Data.Linq;  
    using System.Text;  
    using ExpensesLoadTest;  
    using ArtOfTest.WebAii.Controls.HtmlControls;  
    using ArtOfTest.WebAii.Controls.HtmlControls.HtmlAsserts;  
    using System.Web;  
    using ArtOfTest.WebAii.Core;  
    using ArtOfTest.WebAii.ObjectModel;  
    using ArtOfTest.WebAii.TestAttributes;  
    using ArtOfTest.WebAii.TestTemplates;  
    using Microsoft;  
     
    using ArtOfTest.WebAii.Win32.Dialogs;  
    using System.Drawing;  
    using ArtOfTest.WebAii.Silverlight;  
    using ArtOfTest.WebAii.Silverlight.UI;  
    using ArtOfTest.InternetExplorer;  
    using ArtOfTest.Common;  
     
    using Microsoft.VisualStudio.TestTools.UnitTesting;  
     
    namespace ExpensesLoadTest  
    {  
        /// <summary>  
        /// Summary description for WebAiiVSUnitTest1  
        /// </summary>  
        [TestClass]  
        public class Approve_As_Manager : BaseTest  
        {
            #region [Setup / TearDown]  
     
            private TestContext testContextInstance = null;  
            /// <summary>  
            ///Gets or sets the VS test context which provides  
            ///information about and functionality for the  
            ///current test run.  
            ///</summary>  
            public TestContext TestContext  
            {  
                get 
                {  
                    return testContextInstance;  
                }  
                set 
                {  
                    testContextInstance = value;  
                }  
            }  
     
     
            //Use ClassInitialize to run code before running the first test in the class  
            [ClassInitialize()]  
            public static void MyClassInitialize(TestContext testContext)  
            {  
            }  
     
     
            // Use TestInitialize to run code before running each test  
            [TestInitialize()]  
            public void MyTestInitialize()  
            {
                #region WebAii Initialization  
     
                // Initializes WebAii manager to be used by the test case.  
                // If a WebAii configuration section exists, settings will be  
                // loaded from it. Otherwise, will create a default settings  
                // object with system defaults.  
                //  
                // Note: We are passing in a delegate to the VisualStudio  
                // testContext.WriteLine() method in addition to the Visual Studio  
                // TestLogs directory as our log location. This way any logging  
                // done from WebAii (i.e. Manager.Log.WriteLine()) is  
                // automatically logged to the VisualStudio test log and  
                // the WebAii log file is placed in the same location as VS logs.  
                //  
                // If you do not care about unifying the log, then you can simply  
                // initialize the test by calling Initialize() with no parameters;  
                // that will cause the log location to be picked up from the config  
                // file if it exists or will use the default system settings (C:\WebAiiLog\)  
                // You can also use Initialize(LogLocation) to set a specific log  
                // location for this test.  
     
                // Pass in 'true' to recycle the browser between test methods  
                Initialize(falsethis.TestContext.TestLogsDir, new TestContextWriteLine(this.TestContext.WriteLine));  
     
                // If you need to override any other settings coming from the  
                // config section you can comment the 'Initialize' line above and instead  
                // use the following:  
     
                /*
                // This will get a new Settings object. If a configuration
                // section exists, then settings from that section will be
                // loaded
                Settings settings = GetSettings();
                // Override the settings you want. For example:
                settings.DefaultBrowser = BrowserType.FireFox;
                // Now call Initialize again with your updated settings object
                Initialize(settings, new TestContextWriteLine(this.TestContext.WriteLine));
                */ 
     
                // Set the current test method. This is needed for WebAii to discover  
                // its custom TestAttributes set on methods and classes.  
                // This method should always exist in [TestInitialize()] method.  
                SetTestMethod(this, (string)TestContext.Properties["TestName"]);
           
                #endregion  
     
                //  
                // Place any additional initialization here  
                //  
     
            }  
     
            // Use TestCleanup to run code after each test has run  
            [TestCleanup()]  
            public void MyTestCleanup()  
            {  
     
                //  
                // Place any additional cleanup here  
                //  
     
                #region WebAii CleanUp  
     
                // Shuts down WebAii manager and closes all browsers currently running  
                // after each test. This call is ignored if recycleBrowser is set  
                this.CleanUp();
                #endregion  
            }  
     
            //Use ClassCleanup to run code after all tests in a class have run  
            [ClassCleanup()]  
            public static void MyClassCleanup()  
            {  
                // This will shut down all browsers if  
                // recycleBrowser is turned on. Else  
                // will do nothing.  
                ShutDown();  
            }
            #endregion  
         
     
            [TestMethod]  
            public void ApproveAsManager()  
     
            {  
                
                 
                // Launch a browser instance  
                Manager.LaunchNewBrowser(BrowserType.InternetExplorer);  
     
             
              
                Manager.SetNewBrowserTracking(true);  
                 
              // Add a logon dialog support with username/password  
     
                 
            Manager.DialogMonitor.AddDialog(new LogonDialog(ActiveBrowser, @"ncldev\tusr_mdir""password", DialogButton.OK));  
            Manager.DialogMonitor.Start();  
        
     
            
                  // The active browser  
            ActiveBrowser.NavigateTo("http://ncldevk2.ncldev.co.uk/ncl.TodoList.web.1.0.0.2/ExpandList.aspx");  
     
            ActiveBrowser.Find.ById<HtmlControl>("WucExpandList1_uwgExpandList_ci_0_5_2_imgGo").MouseClick();  
            ActiveBrowser.Find.ById<HtmlButton>("LogOnAsNTUser").Click();  
     
            //Element findSubmitBtn1 = ActiveBrowser.Find.ById("WucExpandList1_uwgExpandList_ci_0_5_2_imgGo");  
            //findSubmitBtn1.As<HtmlImage>().Click();    
     
     
                  
                  
          
     
     
     
            }  
     
        }  
    }  
     

    Reply

  • pearl oguchi avatar

    Posted on May 28, 2010 (permalink)

    Ok the strange thing is that when i run the test now, the MouseClick() action is recognised and a new window opens. I don't know what i did or how i did it. I am just relieved. The only thing now is that if this happens again, I wouldn't know how to fox it.

    This now leaves the 2nd question. How on earth do i attach my test to the new browser window that is opened? I have searched all resources available but nothing solid shows up. This is a very important part of my test and I need it to work, otherwise the purpose of the tool is moot.

    Thanks.

    Pearl

    Reply

  • Answer Nelson Sin Nelson Sin admin's avatar

    Posted on May 28, 2010 (permalink)

    Hi pearl,

    Sorry about the late reply.

    1) Please try using:

    ActiveBrowser.Find.ById<HtmlControl>("WucExpandList1_uwgExpandList_ci_0_5_2_imgGo").Click();

    Click() acts directly on the Page Dom where as MouseClick() simulates a real mouse click. Please use MouseClick() if your page control only reacts to simulated mouse inputs.

    2) It sounds like you are trying to connect to a popup window. If so, please try:

    Manager.WaitForNewBrowserConnect(http://NewWindowURL, true, 5000);
    Manager.ActiveBrowser.WaitUntilReady();


    You should then be able to find page elements using ActiveBrowser.Find...
    Let us know if you still run into any problems with the above.

    Sincerely,
    Nelson Sin
    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.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Automated Testing and WebUI Test Studio > Telerik Testing Framework > My test has stopped opening a new pop up window.
Related resources for "My test has stopped opening a new pop up window."

WebAii Framework Features  |  Documentation |  Videos  |  Webinars  |  Automated Testing Tools  ]