0

我正在尝试使用 Telerik Webaii 测试自动化套件测试 SilverLight Web 应用程序。当我的代码打开浏览器并尝试定向到应用程序 http 地址时,会出现一个登录凭据对话框弹出窗口。该对话框是 IE 的一部分,即它不是 javascript 生成的弹出窗口。我想知道如何使用 Webaii 将焦点转移到登录凭据对话框弹出窗口并输入用户名和密码,然后按 ENTER。到目前为止,这是我的代码(p0 = 网址,p1 = 用户名,p2 = 密码,p3 = 秒):-

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
4

1 回答 1

0

我为 Telerik 工作,并会尽力帮助您。Telerik 测试框架(以前称为 WebAii)有一个登录对话框处理程序,它将为您处理 IE 登录对话框。我们关于如何做到这一点的文档可以在这里找到:http: //docs.telerik.com/teststudio/testing-framework/write-tests-in-code/advanced-topics-wtc/html-popups-and-dialogs- wtc/win32-对话框

于 2015-09-20T21:43:55.083 回答