How can i get the Silverlight aapplication from browser

4 posts, 0 answers
  1. Vali
    Vali avatar
    2 posts
    Member since:
    Sep 2012

    Posted 02 Sep 2012 Link to this post

    Hi folks,

    A few days ago i came across the Telerik Testing framework, so i downloaded it and had it installed, having in mind that i will be able to do a UI test on Silverlight. I am using Visual Studio 2010 and i am trying to open this web page : http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html
    After this i just want to identify a few components from the Silverlight object and perform a few actions.

    So i created a New C# Test Project and added the references to the Telerik framework, wrotw my code and ran the test. The result was that the SilverlightAppsList is gets 1 app, but for some reason it is timed out and i cannot see the SilverlightApp in this list be cause it is not null, but all the members are timed out, as you can see in the screenshot.

    What am i doing wrong?

    My code looks like this:

    using System;
    using System.Text;
    using System.Collections.Generic;
    using System.Linq;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using ArtOfTest.WebAii.Core;
    using ArtOfTest.WebAii.TestTemplates;
    using ArtOfTest.WebAii.Extensions;
    using ArtOfTest.WebAii.Silverlight;
    using ArtOfTest.WebAii.Silverlight.UI;
    using ArtOfTest.WebAii.Silverlight.Attributes;
    using ArtOfTest.Common;
    using ArtOfTest.WebAii.Controls.Xaml;
    using ArtOfTest.WebAii.Controls.HtmlControls;
     
    namespace TestProject7
    {
       
        [TestClass]
        public class UnitTest1
        {
            public UnitTest1()
            {         
            }
     
            private TestContext testContextInstance;
     
            
            public TestContext TestContext
            {
                get
                {
                    return testContextInstance;
                }
                set
                {
                    testContextInstance = value;
                }
            }
     
            [TestMethod]
            public void TestMethod1()
            {
                Settings mySettings = new Settings();
                mySettings.Web.DefaultBrowser = BrowserType.Chrome;
     
                mySettings.ClientReadyTimeout = 120000;
     
                Manager myManager = new Manager(mySettings);
                 
                //must start myManager after creating it
                myManager.Start();
     
                try
                {
                    Settings.Current.Web.EnableSilverlight = true;
                    mySettings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
                    myManager.LaunchNewBrowser();
                    myManager.ActiveBrowser.NavigateTo("http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html");
                    myManager.ActiveBrowser.WaitUntilReady();
                    SilverlightAppsList apps = myManager.ActiveBrowser.SilverlightApps();
     
                    SilverlightApp app = apps.ToArray()[0];
     
                    string ok = "I am glad if this is executed :)";
                }
                catch (Exception e)
                {
                    myManager.Dispose();
                }
     
            }
        }
    }
  2. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 05 Sep 2012 Link to this post

    Hello Vali,

    I'm sorry to hear you are running into this problem.

    FIrst please take the following steps to clear the browser cache:
    1. Start Google Chrome and click the wrench icon on the browser toolbar.
    2. Select Tools.
    3. Select Clear browsing data.
    4. In the dialog that appears, select all checkboxes.
    5. Click Clear browsing data.
    6. Close the browser.

    Then try the following code instead:
    [TestMethod]
    public void TestMethod1()
    {
        Settings mySettings = new Settings();
        mySettings.Web.DefaultBrowser = BrowserType.Chrome;
        mySettings.ClientReadyTimeout = 120000;
        Manager myManager = new Manager(mySettings);
        myManager.Start();
        mySettings.Web.DefaultBrowser = BrowserType.Chrome;
        Settings.Current.Web.EnableSilverlight = true;
     
        //Wait up to 2 minutes for Test Studio to connect to the Silverlight app
        Settings.Current.Web.SilverlightConnectTimeout = 120000;
     
        myManager.LaunchNewBrowser();
        myManager.ActiveBrowser.WaitUntilReady();
     
        //Get the Silverlight app
        SilverlightApp app = myManager.ActiveBrowser.SilverlightApps()[0];
     
        string ok = "I am glad if this is executed :)";
    }


    All the best,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Vali
    Vali avatar
    2 posts
    Member since:
    Sep 2012

    Posted 05 Sep 2012 Link to this post

    Hi Plamen,

    Thanks for your reply. I tried to clear cache and replaced my code with your version, but i am  still getting a timeout exception. I changed the SilverlightConnectionTimeout to 4 minutes, but still this didn't solve my problem.I am attaching a second screenshot to make it more clear. Below is the detail of the error
    System.TimeoutException was unhandled by user code
      Message=Timeout trying to connect to Silverlight App.
      Source=ArtOfTest.WebAii
      StackTrace:
           at ArtOfTest.WebAii.Silverlight.SilverlightApp.WaitUntilExtensionCreated(String extensionCall)
           at ArtOfTest.WebAii.Silverlight.SilverlightApp.Connect(Int32 timeout)
           at ArtOfTest.WebAii.Silverlight.SilverlightApp.Connect()
           at ArtOfTest.WebAii.Silverlight.SilverlightAppsList.get_Item(Int32 index)
           at TestProject7.UnitTest1.TestMethod1() in C:\Users\ValiMobile\documents\visual studio 2010\Projects\TestProject7\TestProject7\UnitTest1.cs:line 85
      InnerException:

    Do you have any other ideas about this?


  4. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 11 Sep 2012 Link to this post

    Hi Vali,

    Which version of Telerik Testing Framework you are currently using? If you haven't done so already, please upgrade to our latest internal build 2012.1.822. 

    If the issue persists with the new version, please try the following:
    1. Delete the old “Telerik TestStudio” extension from Chrome->Settings->Extensions.
    2. Download the attached extension file, extract and drag&drop it to the Chrome extensions window. Chrome will ask for confirmation and will load the new extension.
    3. Clear the browser cache.
    4. Run the test again.

    All the best,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top