0

I am trying to test a SilverLight web application using the Telerik Webaii test automation suite. When my code opens the browsers and tries to direct to the applications http address a login credentials dialogue popup appears. The dialogue box is part IE i.e. it is not a javascript generated popup. I was wondering how I can use Webaii to shift focus to the login credentials dialogue popup and enter a user name and password, then press ENTER. Here is my code so far (p0 = web address, p1 = username, p2 = password, p3 = seconds):-

using System;
using System.Windows;
using System.Linq;
using System.Threading;
using ArtOfTest.WebAii.Core;
using ArtOfTest.WebAii.Win32.Dialogs;
using ArtOfTest.WebAii.Silverlight;
using ArtOfTest.WebAii.Silverlight.UI;
using NUnit.Framework;
using TechTalk.SpecFlow;
using Telerik.WebAii.Controls.Xaml;
using TimeSpan = System.TimeSpan;
using System.Collections.Generic;

using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Security.Permissions;
using System.ComponentModel;

namespace PortalTestSuite.Tests.Definitions
{
    [Binding]
    public class SmokeTestsSteps
    {

        private SilverlightApp _silverlightApp;
        public Manager _browserManager;

        [BeforeScenario()]
        public void BeforeScenario()
        {


        }

        [AfterScenario()]
        public void AfterScenario()
        {
            var buttons = _silverlightApp.Find.AllByType<Button>();
            _browserManager.ActiveBrowser.Close();
            _browserManager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter);
        }

            [Given(@"I can navigate to ""(.*)"" using IE with username ""(.*)"" and password ""(.*)"" page load tolerance of (.*) seconds")]
            public void GivenICanNavigateToUsingIEWithUsernameAndPasswordPageLoadToleranceOfSeconds(string p0, string p1, string p2, int p3)
            {
                var mySettings = new Settings
                {
                    Web = { DefaultBrowser = BrowserType.InternetExplorer },
                    ClientReadyTimeout = 60000
                };
                _browserManager = new Manager(mySettings);
                _browserManager.Start();

                Settings.Current.Web.EnableSilverlight = true;
                _browserManager.LaunchNewBrowser();
                _browserManager.ActiveBrowser.Window.Maximize();
                _browserManager.SetNewBrowserTracking(true);

                _browserManager.ActiveBrowser.NavigateTo(p0);

                //When login credentials popup appears enter user credentials here
ED209
  • 588
  • 1
  • 9
  • 26

1 Answers1

0

I work for Telerik and will try to help you with this. The Telerik Testing Framework (formerly called WebAii) has a Logon dialog handler that will handle the IE logon dialog for you. Our documentation on how to do this can be found here: http://docs.telerik.com/teststudio/testing-framework/write-tests-in-code/advanced-topics-wtc/html-popups-and-dialogs-wtc/win32-dialogs

sircody
  • 214
  • 1
  • 5