欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

批量賬號(hào)的login測(cè)試功能實(shí)現(xiàn)

 更新時(shí)間:2012年11月23日 12:00:58   作者:  
用WaitiN寫(xiě)了個(gè)簡(jiǎn)單的login自動(dòng)化測(cè)試,能夠使用少量的代碼實(shí)現(xiàn)批量賬號(hào)的login測(cè)試,需要的朋友可以參考下
用WaitiN寫(xiě)了個(gè)簡(jiǎn)單的login自動(dòng)化測(cè)試,能夠使用少量的代碼實(shí)現(xiàn)批量賬號(hào)的login測(cè)試
很簡(jiǎn)單的,代碼如下:

復(fù)制代碼 代碼如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WatiN.Core;

namespace ConsoleApplication1
{
class Program
{
[STAThread]
static void Main(string[] args)
{
List<LoginTester.LoginAccount> Accounts = new List<LoginTester.LoginAccount>();
Accounts.Add(new LoginTester.LoginAccount() { UserName = "your user account", Password = "aaaaa", ShouldSuccess = false });
Accounts.Add(new LoginTester.LoginAccount() { UserName = "your user account", Password = "", ShouldSuccess = false });
Accounts.Add(new LoginTester.LoginAccount() { UserName = "your user account", Password = "your password", ShouldSuccess = true });

LoginTester tester = new LoginTester("http://passport.cnblogs.com/login.aspx", "http://home.cnblogs.com", "tbUserName", "tbPassword", "btnLogin");
tester.BrowserVisible = true;
Accounts.ForEach(t=>tester.ExecuteTest(t.UserName, t.Password, t.ShouldSuccess));


Console.WriteLine("\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n");
Console.WriteLine("************Test Report Summary****************");
Console.WriteLine(tester.ReportSummary);
}

public class LoginTester
{
public class LoginAccount
{
public string UserName { get; set; }
public string Password { get; set; }
public bool ShouldSuccess { get; set; }
}


private string loginUrl = string.Empty;
private string loginSuccessForwaredUrl = string.Empty;
private string loginButtonName = string.Empty;
private string userNameFieldName = string.Empty;
private string passwordFieldName = string.Empty;
public string ReportSummary { get; private set; }
public bool BrowserVisible { get; set; }

public LoginTester(string loginUrl, string loginSuccessForwaredUrl, string userNameFieldName, string passwordFieldName, string loginButtonName)
{
this.loginUrl = loginUrl;
this.loginSuccessForwaredUrl = loginSuccessForwaredUrl;

this.userNameFieldName = userNameFieldName;
this.passwordFieldName = passwordFieldName;
this.loginButtonName = loginButtonName;
}

public void ExecuteTest(string userName, string password, bool loginSuccess)
{
string msg = string.Format("用戶(hù)名: {0}, 密碼: {1}, 期望能否登錄: {2}", userName, password, loginSuccess);

using (IE browser = new IE(this.loginUrl))
{
browser.Visible = this.BrowserVisible;
browser.TextField(Find.ByName(this.userNameFieldName)).TypeText(userName);
browser.TextField(Find.ByName(this.passwordFieldName)).TypeText(password);
browser.Button(Find.ByName(this.loginButtonName)).Click();

bool loginIsSuccess = browser.Url.IndexOf(this.loginSuccessForwaredUrl, StringComparison.OrdinalIgnoreCase) >= 0;

msg = string.Format("{0}\r\n {1}", msg, loginIsSuccess == loginSuccess ? "Successful" : "Failed");
ReportSummary += msg+"\r\n";
Console.WriteLine(msg);
}
}
}
}

源代碼下載

相關(guān)文章

  • ASP.NET實(shí)現(xiàn)根據(jù)IP獲取省市地址的方法

    ASP.NET實(shí)現(xiàn)根據(jù)IP獲取省市地址的方法

    這篇文章主要介紹了ASP.NET實(shí)現(xiàn)根據(jù)IP獲取省市地址的方法,主要基于QQwry.dat純真IP數(shù)據(jù)庫(kù)來(lái)實(shí)現(xiàn)這一功能,非常實(shí)用,需要的朋友可以參考下
    2014-10-10
  • .NET中利用js讓子窗體向父頁(yè)面?zhèn)髦档膶?shí)現(xiàn)方法

    .NET中利用js讓子窗體向父頁(yè)面?zhèn)髦档膶?shí)現(xiàn)方法

    .NET中利用js讓子窗體向父頁(yè)面?zhèn)髦档膶?shí)現(xiàn)方法,需要的朋友可以參考一下
    2013-02-02
  • 深入Lumisoft.NET實(shí)現(xiàn)郵件發(fā)送功能的方法詳解

    深入Lumisoft.NET實(shí)現(xiàn)郵件發(fā)送功能的方法詳解

    本篇文章對(duì)使用Lumisoft.NET實(shí)現(xiàn)郵件發(fā)送功能的方法機(jī)型了詳細(xì)的分析介紹。需要的朋友參考下
    2013-05-05
  • asp.net Silverlight中的模式窗體

    asp.net Silverlight中的模式窗體

    現(xiàn)在Web開(kāi)發(fā)技術(shù)中流行著模式窗體,這種不用跳轉(zhuǎn)頁(yè)面又能夠滿足與用戶(hù)進(jìn)行數(shù)據(jù)交互的手段確實(shí)不錯(cuò),那我今天也談?wù)凷ilverlight中的模式窗體吧。
    2009-11-11
  • .NetCore使用過(guò)濾器實(shí)現(xiàn)登錄權(quán)限認(rèn)證的方法小結(jié)

    .NetCore使用過(guò)濾器實(shí)現(xiàn)登錄權(quán)限認(rèn)證的方法小結(jié)

    這篇文章主要介紹了.NetCore使用過(guò)濾器實(shí)現(xiàn)登錄權(quán)限認(rèn)證幾種方式總結(jié),主要包括自定義行為過(guò)濾器在OnActionExecuting中實(shí)現(xiàn),自定義身份驗(yàn)證過(guò)濾器,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友參考下吧
    2022-06-06
  • asp.net 支付寶及時(shí)到帳接口使用詳解

    asp.net 支付寶及時(shí)到帳接口使用詳解

    這兩天寫(xiě)支付寶接口, 這個(gè)話題不新了, 因?yàn)楹芏嗳硕?做過(guò)了, 在這里我說(shuō)說(shuō)我的看法吧, 先說(shuō)一下實(shí)現(xiàn)
    2010-03-03
  • 使用SNK密鑰文件保護(hù)你的DLL和代碼不被反編譯教程

    使用SNK密鑰文件保護(hù)你的DLL和代碼不被反編譯教程

    這篇文章主要介紹了使用SNK密鑰文件保護(hù)你的DLL和代碼不被反編譯教程, SNK,作為程序后綴的時(shí)候,是.net中的強(qiáng)密匙加密文件,需要的朋友可以參考下
    2014-09-09
  • 最新評(píng)論