Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

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

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!!!


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

11/14/2011

Creates GUI Map file from Selenium IDE

1. Open Selenium IDE Options
2. In the [Formats] tab, clicks [Add] button
3. Name the format as GUI Map
4. Replace the source code by below code
5. Click [Save]  button
6. Record some steps by Selenium IDE
7. Rename the command to Object Name format
8. On Selenium IDE, click File>>Export Test Case As >> GUI Map



var SEPARATORS = {
    comma: ",",
    tab: "\t"
};

function formatCommands(commands) {

    var sep = SEPARATORS[options['separator']];
    var result = 'Property ' + sep + 'Value' + "\n";
    for (var i = 0; i < commands.length; i++) {
        var command = commands[i];
        if (command.type == 'command') {
            result += command.command + sep + command.target + sep + command.value + "\n";
        }
    }
    return result;
}

function parse(testCase, source) {
    var doc = source;
    var commands = [];
    var sep = SEPARATORS[options['separator']];
    while (doc.length > 0) {
        var line = /(.*)(\r\n|[\r\n])?/.exec(doc);
        var array = line[1].split(sep);
        if (array.length >= 3) {
            var command = new Command();
            command.command = array[0];
            command.target = array[1];
            command.value = array[2];
            commands.push(command);
        }
        doc = doc.substr(line[0].length);
    }
    testCase.setCommands(commands);
}

function format(testCase, name) {
    return formatCommands(testCase.commands);
}

options = { separator: 'comma' };


configForm =
    '<description>Separator</description>' +
 '<menulist id="options_separator">' +
 '<menupopup>' +
 '<menuitem label="Comma" value="comma"/>' +
 '<menuitem label="Tab" value="tab"/>' +
 '</menupopup>' +
 '</menulist>';