开发者

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

开发者 https://www.devze.com 2023-02-22 19:46 出处:网络
I have an webforms application that I would like to create some automated tests for.This application currently implements Forms 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

精彩评论

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