开发者

How do you do automated testing with a webforms app that uses Froms Authentication?

I have an webforms application that I would like to create some automated tests for. This application currently implements Forms Authentication.

What is the b开发者_StackOverflowest way to accomplish this?


You can use an automated tool such as Selenium or Watin to help drive the test through Internet Explorer or Firefox. At my company, we automate all front end tests using C#, Watin, and Gallio (mbUnit).

You will need to use a tool such as Developer Tools on IE to discover the names/ids of web controls such as textboxes and buttons. Once you have them, you can create Watin objects to represent them. Watin provides basic classes such as Button and TextField.

public class SignInPage
{
    public Button SignInButton { get { return Document.Button(Find.ByName(new Regex("login"))); } }
    public TextField UserNameEmailTextField { get { return Document.TextField(Find.ByName(new Regex("userNameEmail"))); } }
    public TextField PasswordTextField { get { return Document.TextField(Find.ById(new Regex("password"))); } }
............
}

Then you will drive the test through the SignInPage object.

  Browser.Page<SignInPage>().UserNameEmailTextField.Value = userName;
  Browser.Page<SignInPage>().PasswordTextField.Value = password;
  Browser.Page<SignInPage>().SignInButton.Click();

This same procedure is also easily accomplished with Selenium.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜