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

Opening the Silverlight web page

6 Answers 35 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Amardeep
Top achievements
Rank 1
Amardeep asked on 31 Jul 2013, 03:15 PM
HI, 

I am new to TTF, and I am learning to build the framework within our company. I am trying to open the silverlight web page but getting errors.
I am using the method under to open the webpage:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ArtOfTest.WebAii.TestTemplates;
using ArtOfTest.WebAii.Silverlight;
using ArtOfTest.WebAii.Silverlight.UI;
using System.Diagnostics;
using System.IO;
using ArtOfTest.WebAii.Core;
using ArtOfTest.WebAii.ObjectModel;
using ArtOfTest.WebAii.TestAttributes;
using ArtOfTest.WebAii.Win32.Dialogs;
using ArtOfTest.WebAii.Controls.HtmlControls;



namespace WebPortalTests
{
    [TestClass]
    public class CreateCharts :BaseTest
    {
        public SilverlightApp OpenApplication()
        {
            Manager.Settings.Web.EnableSilverlight=true;
            Manager.LaunchNewBrowser();
            ActiveBrowser.Window.Maximize();
            ActiveBrowser.NavigateTo("http://Some web page");
            SilverlightApp app = ActiveBrowser.SilverlightApps();
            return app;
        }

    }
}

Can you please tell me if I am using the right API method to open the webpage? IF yes what is going wrong in the method?

6 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 01 Aug 2013, 08:35 AM
Hi Amardeep,

Here is how your code should look like:

[TestClass]
   public class TelerikVSUnitTest1 : BaseTest
   {
           [TestMethod]
       public void SampleWebAiiTest()
       {
           Manager.Settings.Web.EnableSilverlight = true;
           Manager.LaunchNewBrowser();
           ActiveBrowser.Window.Maximize();
           ActiveBrowser.NavigateTo("http://demos.telerik.com/silverlight/");
           SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
           
       }
 
   }
 
Firstly you should have [TestMethod] to indicate which part of the code is a test method. Another thing is that the method must have a return type. This sample is returning void, so you don't need to have this line of code: return app;

The last thing is that ActiveBrowser.SilverlightApps() returns an array of all SL applications on the page, so you have to use index also: SilverlightApp app = ActiveBrowser.SilverlightApps()[0];

Hope this helps.

Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Amardeep
Top achievements
Rank 1
answered on 01 Aug 2013, 03:06 PM
HI Boyan, 
Thanks for your reply.
I have changed the code but getting the NullReferenceException. Do I need to initialize the Manager class?
Please see the attached file for the exception

namespace WebPortalTests
{
    [TestClass]
    public class CreateCharts :BaseTest
    {
        [TestMethod]
        public void OpenApplication()
        {  
            
            Manager.Settings.Web.EnableSilverlight = true;
            Manager.LaunchNewBrowser();
            ActiveBrowser.Window.Maximize();
            ActiveBrowser.NavigateTo("http://ab-m4500/AthenePortal/Presentation.WRClient.html");
            SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
 
        }
 
    }
}
0
Boyan Boev
Telerik team
answered on 05 Aug 2013, 10:07 AM
Hello Amardeep,

Yes you might need to initialize it. Here is an example code:

Settings mySettings = new Settings();
mySettings.Web.DefaultBrowser = BrowserType.InternetExplorer;
mySettings.Web.EnableSilverlight = true;
Manager myManager = new Manager(mySettings);
myManager.Start();
myManager.LaunchNewBrowser();
myManager.ActiveBrowser.NavigateTo("URL", false);
 
Before that please try to modify you code with manager.current:

namespace WebPortalTests
 
{
 
    [TestClass]
 
    public class CreateCharts :BaseTest
 
    {
 
        [TestMethod]
 
        public void OpenApplication()
 
        {   
 
              
 
            Manager.Current.Settings.Web.EnableSilverlight = true;
 
            Manager.Current.LaunchNewBrowser();
 
            ActiveBrowser.Window.Maximize();
 
            ActiveBrowser.NavigateTo("http://ab-m4500/AthenePortal/Presentation.WRClient.html");
 
            SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
 
   
 
        }
 
   
 
    }
 
}

Let me know if you need further assistance.

Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Alex
Top achievements
Rank 1
answered on 09 Sep 2014, 07:57 AM
Good day 
I also learn TTF and encountered this error message:
"An exception of type 'System.ArgumentException' occurred in ArtOfTest.WebAii.dll but was not handled in user code
Additional information: Index '0' is invalid. List contains only '0' apps".

My code:
        public void First()
        {
            // Enable Silverlight
            Settings.Current.Web.EnableSilverlight = true;
            
            // Launch a browser instance
            Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
            
            // Navigate to the page
            ActiveBrowser.NavigateTo("some url");
            
            //Login
            Find.ByAttributes<HtmlDiv>("data-thumbprint=~900ACBBBBFCFE71EEA6C5F3A1A6CDE97EF5E0C3B").Click();
            System.Threading.Thread.Sleep(20000);
            
            // Get an instance of our Silverlight app.
            SilverlightApp app = ActiveBrowser.SilverlightApps()[0];

Tell me, please, what's the problem?
0
Vitaliy
Top achievements
Rank 1
answered on 10 Sep 2014, 07:27 AM
If the use of Manager.LaunchNewBrowser(BrowserType.AspNetHost) tests will be executed or not? or use the BrowserType.SilverlightOutOfBrowser ?
0
Ivaylo
Telerik team
answered on 12 Sep 2014, 08:06 AM
Hello Amardeep,

Please confirm you are using valid Silverlight application. The best approach here will be providing access to the tested application with the test you are trying to execute so we can assist further.

Regards,
Ivaylo
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Amardeep
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Amardeep
Top achievements
Rank 1
Alex
Top achievements
Rank 1
Vitaliy
Top achievements
Rank 1
Ivaylo
Telerik team
Share this question
or