3/06/2012

Add more configuration items to the configs.csv

By default, SelDotNet only get default setting values for


  • Language
  • Browser
  • Base Url
  • Timeout
  • Connection String
  • Auto Capture Screenshot
  • Default Username
  • Default Password

If you want to get more settings from configs.csv file, please follow these following steps.
  1. Add as many property/value as to the configs.csv file.
    Example: Project Name, SelDotNet Implementation
  2. In the Entry Point Class that inherits from BaseTest Project, Override the virtual method
        const string PROJECT_NAME ="Project Name";
        protected override void DoLoadCustomConfigs(Configuration conf)
        {
            Engine.Configs.AddProperty(
                PROJECT_NAME, 
                conf.GetProperty(PROJECT_NAME)
                );
        } 
    
  3. Later, everytime you want to get this value, just  call
        Engine.Configs.GetProperty(TheProject.PROJECT_NAME);
    

Flexible selecting item for listbox and radio group

For listbox and radio group, SelDotNet has implemented some useful methods, such as:
SelectByValue(value);
SelectByIndex(index);
SelectByText(text);
SelectFirstItem();
SelectLastItem();
AutoSelect();
Actually, it is not the most useful. Since, sometime you have to write much code like this.

if (testcase==AUTOSELECT_JOBTITLE)
jobTitle = Listbox("JobTitle").AutoSelect();
else
jobTitle = Listbox("JobTitle").SelectByText(aJobTitle);
to avoid this much waste of time, SelDotNet provide an alternative solution. By that, you just assign to jobTitle one of these value:
Listbox.FIRST_ITEM
Listbox.LAST_ITEM
Listbox.RANDOM_ITEM
Listbox.SELECT_NOTHING
Listbox.ITEM_INDEX + anumber

Example
void MakeTestData(TestCase testcase){
    MemberInfo member = MemberInfo.MakeStandardTestData();
    switch(testcase){

    case: EMPTY_JOBTILE:
         member.JobTitle =  Listbox.SELECT_NOTHING; 
    break;
    }
}

void SubmitData(MemberInfo member){
     ...
     //We dont need branching here
      Listbox("JobTitle Listbox").SelectByText(member.JobTitle);
      ...
}

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!

2/22/2012

Make Test Data Secured

/// Loads test db:
        /// 1. Gets query string from sheet "AdminLogin"
        /// 2. Executes that query
        /// 3. Return the db
        private string[][] TestData_AdminLogin()
        {
            string sql="select top 2 username, password from tblAdmin";
            //Make the column #2 as secured data
            return MakeSecureTestData(LoadTestData_ExecSQL(sql),1);//0-based column.
        }        

        /// 
        /// Action: Login as admin        
        /// Condition: correct username, newPassword        
        /// Expected: show admin menu after logged
        /// Post-condition: logout and close browser
        /// 
        /// 

correct username
        /// 

correct newPassword
        [TestCaseSource("TestData_AdminLogin")] 
        public void TC01_AdminLogin_WithCorrectCredential_ShowAdminMenu(string username, string password)
        {                   
            homePage.SubmitLoginForm(username, password,true);
            homePage.Dispose();
            AdminBasePage adminPage = new AdminBasePage(homePage.GetBrowser());
            adminPage.AssertIsLoaded();
            adminPage.Logout();
            adminPage.Close();
        }

Released VS Project Templates for SelDotNet 1.0

Please follow these steps to create SelDotNet project:

  1. Open Visual Studio 2010
  2. File>New Project
  3. In the New Project Dialogbox, choose 'Online templates'
  4. Search SelDotnet like below picture
    1. Empty project: Just structure of a SelDotNet project.  You have to download asssemblies and pastes to Implementation\References folder  and write some code
    2. Sample: A login sample code that use SelDotNet. You have to download asssemblies and pastes to Implementation\References folder.
    3. SelDotNet Full: includes both of login sample code and assemblies. You just have to build project and use  NUnit to run that assembly.
Good luck!!!


NUnit Releases NUnit 2.6 Final


NUnit 2.6 Final Release - Version 2.6.0.12051 - February 20, 2012

General

  • Support for .NET 1.0 / 1.1 is no longer included in the main distribution for NUnit but is provided as a separate package.
  • NUnit's executables now use config files that allow smoother running of mixed assemblies built for .NET 2.0 under .NET 4.0.
  • When opening Visual Studio formatted solutions, NUnit now uses the solution configuration by default, resulting in changed behavior from previous releases. The Settings Dialog may be used to revert NUnit to the earlier behavior, which ignored solution configurations.
  • NUnit Mocks is now deprecated. All classes are now marked as obsolete. NUnit now uses the NSubstitute mock framework its own tests. A copy of the NSubstitute dll is included in the distribution.
  • NUnit no longer stores settings in the test configuration file, as it did in earlier versions. Specifically, we no longer recognize or support
    • OldStyleTestCases
    • ApartmentState
    • ThreadPriority
    • DefaultLogThreshold
  • Changing the URL to be used for NUnit help through NUnit's config file is no longer supported.

Development

  • NUnit is now built using .NET 3.5 or higher. All NUnit assemblies and most tests target .NET 2.0 but the full set of tests requires 3.5 or greater to execute. The build script selects either .NET 3.5 or .NET 4.0 to perform the build, depending on what is available. A Visual Studio 2008 solution is also provided.
  • NAnt 0.91 release is now used for building.
  • The Windows installer is now built using WiX 3.5, upgraded from 2.0.
  • The TestRunner interface has been modified. Applications using this interface will need to be modified but general users are not effected.

Framework

  • NUnit now supports composable Action Attributes, which allow the test developer to put reusable test actions into attributes and attach these actions to suites, tests, and test cases. The actions can run arbitrary code before and after suites, tests, and test cases execute. It enables the test developer to build smaller reusable actions and to compose them in unique ways for each suite, test, or test case.
  • The following Attributes have changes in NUnit 2.6:
    • TestCaseAttribute now accepts Explicit and Reason named parameters.
    • TestCaseSourceAttribute now accepts a Category named parameter.
    • TestCaseData now supports marking individual test cases as Explicit.
    • EqualConstraint now recognizes and uses IEquatable<T> if it is implemented on either the actual or the expected value. The interface is used in preference to any override of Object.Equals(), so long as the other argument is of Type T. Note that this applies to all equality tests performed by NUnit.
    • PlatformAttribute accepts "Windows8", "Windows2012Server", "Net-3.0", "Net-3.5", "Mono-3.0" and "Mono-3.5" as arguments.
      Note: Since the 3.0 and 3.5 frameworks all use the 2.0 runtime, the semantics of their use is slightly different from other key words. The "3.5" arguments also include "3.0" and "2.0" and the "3.0" arguments include "2.0" in their interpretation.
    • TestFixtureAttribute now accepts a Category named parameter, allowing individual fixture instances to be included in or excluded from a test run.
  • The following additions have been made to the Constraint syntax:
    • User-defined equality comparers specified with the Using syntax element may now be used with collections, arrays and dictionaries. The Using(...) syntactic element may be repeated multiple times in an expression, so long as each comparer applies to a different Type. NUnit will use the appropriate comparer, depending on the Type of the arguments. Among other things, this allows overriding the default NUnit comparison of collections, arrays and dictionaries.
    • Is.Positive may be used as a synonym for Is.GreaterThan(0).
    • Is.Negative may be used as a synonym for Is.LessThan(0).
    • Has.Exactly(n)... may be used in place of Has.Some... in order to allow tests over collections that must be satisfied a specific number of times.
  • When Assert.Throws() fails due to an exception of the wrong Type being thrown, the error message now includes the Message and Stack Trace from the exception.
  • Visual Basic users may now use Assert.ByVal rather than Assert.That() to avoid errors when the first argument is a property with a non-public setter.
  • Documentation is provided for the previously undocumented TestContext. A new propertyTestContext.WorkDirectory allows tests to access the name of a directory to be used for file output. This directory may be specified by use of the /work option of nunit-console.
  • So-called "old-style" tests, identified by having a name beginning with "Test" are no longer supported in NUnit 2.6.
  • Setting a ThreadPriority for the test runner thread is no longer supported under NUnit 2.6.

Console

  • The following new command-line options are provided:
    • -result is a synonym for -xml, specifying the file to be used for output of the test results in XML form. The -xml option is still recognized but will be removed in a future release.
    • -noresult allows supressing the xml result output entirely.
    • -work is used to specify the directory to be used for output files. Any relative paths specified with the -output-err or -result options are resolved using this directory as a base.
    • -runlist allows the user to specify a file that contains the names of the tests to be executed rather than listing them directly on the command line.
    • -stoponerror causes execution of the test run to terminate immediately on the first test failure or error.
    • -apartment is used to specify the ApartmentState (STA or MTA) of the test runner thread. Since the default is MTA, the option is only needed to force execution in the Single Threaded Apartment.
  • The .NET 1.1 build of nunit-console no longer supports the -process or -frameworkoption. There is no automatic runtime detection and tests execute under same runtime as the console runner itself. If this functionality is needed when running tests under .NET 1.1, use the standard console runner to execute the tests in a separate process.

Gui

  • The Project Editor is now a separate program, which may be executed directly or run through the Project | Edit dropdown menu of the NUnit GUI. The editor now provides two main views of the project: a property-oriented view based on the Project Editor that was built into earlier versions of the NUnit GUI and an xml view, which allows simple editing of the .nunit file.
  • The Gui now displays invalid tests in red immediately upon load, without waiting for the user to run them. Tests marked with the IgnoreAttribute are displayed in yellow immediately as well.
  • The test reload functionality in the Gui has been rewritten and simplified so that the same logic is used for all cases where the visual state of the tree is to be recovered. Test results are now found even if changes to the assembly have resulted in the assignment of new ids to the tests.
  • A number of new settings are available using the Settings Dialog:
    • The Tree Display page allows the user to select alternate image sets for use in the test tree. Additional user-provided image sets may be added if desired.
    • The Text Output page allows setting the threshold for capture and display of log4net output (previously controlled by the test config file).
    • The Project Editor page allows the user to select whether the NUnit Project Editor or another external program will be used when editing the settings file.
    • The Runtime Selection page allows enabling or disabling automatic detection of the target runtime for each test assembly.
    • The Advanced Loader Settings page now allows specifying the argument to use in calling SetPrincipalPolicy for each test AppDomain.
    • The Visual Studio page now includes a setting that enables or disables the use of solution configs when loading Visual Studio solution files.
    • The Internal Trace page now shows the directory path to which log files will be saved.
  • The location of the settings dialog under the Windows AppData directory has been changed from Roaming to Local. Users will need to reset their preferences in some cases.
  • By default, test Cases under a Theory that fail an assumption are no longer shown in the tree. A context menu item has been added to allow the user to view them.
  • The properties dialog has been redesigned to be more compact and readable.
  • The context menu for the test tree has been simplified.
  • The directory containing the log files may be opened directly from the Gui by use of a new item on the Tools menu.
  • Test summary results are truncated when the window size is too small. The full summary is displayed when hovering over the field.

PNUnit

  • The PNUnit code has been updated using the latest build from the developers at Codice Software and additional examples are provided in the source.

11/24/2011

Disable Information bar in Internet Explorer browser


Information bar in IE browser disturbs us so much. Moreover, we cannot run automation test if this feature is enable. Below steps guide us how to disable it.

  1. Run regedit.exe to edit registry
  2. HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_LOCALMACHINE_LOCKDOWNSet the REG_DWORD for iexplorer.exe to a value of 0 to disable LMZ Lockdown
  3. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_LOCALMACHINE_LOCKDOWN
  4. Set the REG_DWORD for the following to a value of 0 to disable LMZ Lockdown


  • explorer.exe REG_DWORD Value 0
  • iexplorer.exe REG_DWORD Value 0
  • msimn.exe REG_DWORD Value 0
  • wmplayer.exe REG_DWORD Value 0