SilverLight Webaii测试自动化-在IE对话框中输入用户凭据

本文关键字:输入 用户 对话框 IE 测试 Webaii 自动化 SilverLight | 更新日期: 2023-09-27 18:12:51

我正在尝试使用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

SilverLight Webaii测试自动化-在IE对话框中输入用户凭据

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