3/05/2012

A New Approach with SelDotNet

As mentioned in the earliest version of SelDotNet, user is suggested to create a page class for each page under test. Obviously, this approach is clearly and easy to maintain.

TRADITIONAL APPROACH

class LoginPage : BasePage{
   public LoginPage(IWebDriver browser):base(browser){
      LoadMap(" mapping file");
   }
   public void Action1(){}
   public void Action2(){}
   public void CheckTheResult(){}
}

class TFxxx_LoginTest: BaseTestFixture{

    [Test]
    public void ATest(){
       LoginPage page = new LoginPage( StartBrowser());
       page.Action1();
       page.Action2();
       page.CheckTheResult();
       page.Close();                   
   }
}
However, SelDotNet also supports an alternative approach, that is like the QTP's style. The script should be like this
class TFxxx_LoginTest: BaseTestFixture{
   
   ProjectBasePage page= null;

   public override void  DoFixtureSetUp()
        {            
            page =  new ProjectBasePage(StartBrowser());
            page.LoadMap("A gui map file");
        }

   [Test]
    public void ATest(){
       page.Editbox("Username").Set("username");               
       page.Editbox("Password").SetSecure("@#$%^&*()_");
       page.Button("Submit").Click();
       page.AssertContainText("Welcome to the system");
   }
}
With this new approach, we don't need to create a class for every page under test. Depending on your situation, then you should select an appropriated approach. Good luck!

No comments:

Post a Comment