locked
About keyword driven

    Question

  • Hi, I want to know how can i implement the keyword driven approach by Coded UI test tool?
    Monday, January 17, 2011 8:40 AM

Answers

  •  

    Hi Anne

    Sure essentially you have a spreadsheet that looks something like this that contains your test flows where keywords and data are passed through processors and lead to common code (below in data Member;1 means go to sheet Member row 1 for data for that action)

    Hope this shows well (it's part of something I gave to Parasoft as an example & not real).

    FlowControl Keyword Data Options Expected
      KWD.Test.StartTest Login & Select Member    

    Client.AdminLogin

    ProcessSuccessful

    Client.Member.SelectMember Member;1 Set="flow2" ProcessSuccessful
      KWD.Test.EndTest      

    KWD.Test.StartTest Test 2 runs if select member failed - otherwise skips  
    flow2 Client.Member.SelectMember Member;2 Fail ProcessSuccessful

    KWD.Test.EndTest      

    Client.Logout

    ProcessSuccessful

     

    then member sheet will contain relevant data columns for the action to keep this simple only really SIN would be used here but obviously what's here is related to what you need.

     

    Comments SIN
    Active Member 123456789

    Then your code for handling SelectMember will read in the data and use it to complete the predefined action. It should likely be a part of a related class which inherits common function/implements ones like read from a data table. You should use a set of common functions to handle interactions with app objects here's an example of one of mine

     

          

     public static Status Set(HtmlEdit oEdit, String sValue, String sInfo)
        {
          Status oStatus = new Status();
    
          if (sValue.Equals("!DEFAULT!"))
          {
            GlobalVars.Logger.ReportEvent(GlobalVars.Done, "Skipping EditBox Entry " + sInfo, "Value is default no changes made");
            return oStatus;
          }
    
    
          try
          {
            oEdit.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);
    
            oEdit.Text = sValue;
    
            GlobalVars.Logger.ReportEvent(GlobalVars.Done, "Set Edit Value " + sInfo, "Set Value [" + sValue + "]");
          }
          catch (Exception e)
          {
            // a failure here doesn't imply a test failure just an object set failure (could be expected)
            GlobalVars.Logger.ReportEvent(GlobalVars.Done, "Couldn't set HtmlEdit " + sInfo, "Error Unable to set value [" + sValue + "] hit Exception [" + e.Message + "]");
            oStatus.Fail();
          }
    
          return oStatus;
    
        }
    

    Honestly there's more information than I can possibly share in a post here, you should be able to find some resources online. At the very least You're going to wind up committing to writing a methodology to process keywords, read your data from a source (most people use excel sheets), Interact with your application & determine the results of that interaction (both for individual actions like above, and larger actions being the keywords you write), and very likely generate your own results based on everything you did & saw (which in my opinion leads to much better results).

     

    If you need further information drop an e-mail and I'll see about contacting you, can't really spend much time doing this during the day.

    Friday, March 11, 2011 7:10 PM

All replies

  • I've done it & it works fine (keyword data hybrid framework, because pure keyword is much less maintainable & slows script development). Just expect to generate your own results entirely probably (I did by design from the onset). Also I threw out the recorded objects & defined my own from search properties, don't know how well using the built in generated code files will work or not as they weren't an ideal for the applications I support (not saying they won't work, just haven't used them myself so I can't state that they did).
    Friday, February 25, 2011 9:04 PM
  • Hi,

    Its not possible to discuss the entire Keyword driven framework using VSTS Coded UI Test but the idea remains the same as it is usually done in any tool like QTP. Keep your keywords in an excel sheet, write wrappers around the existing CodedUITest APIs that will read your excel and based upon the keywords provided, you can identify the controls and based upon the control type you can perform any supported action. You can leverage upon the available drivers to iterate through the excel sheets. Another idea can be to use a database instead of excel sheets.

    Regards,

    Pankaj

    • Proposed as answer by Dexter.ce Friday, March 11, 2011 8:11 AM
    Tuesday, March 1, 2011 10:40 PM
  • Could you please give me a simple example about this.
    Thursday, March 3, 2011 9:47 AM
  • I guess you are looking for various keyboardstrokes

    Refer this for the list of various keyboard strokes

    http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx


    ---Mark this post if this Answers or Helps---
    Cheers
    FunnyFox
    Thursday, March 3, 2011 12:53 PM
  • Have you thought about buying a framework? See http://visualstudiogallery.msdn.microsoft.com/1e605ead-bfe4-4996-8586-bb83fae0622d

    I do not work them, just used the framework for many years now.

    Thursday, March 3, 2011 3:05 PM
  • Hi MHSK,

    Did you get any solution for this. I am looking for the same kind of Keyword Driven Automation framework for my CUI Tests.

    Please do the needfull.

    Thanks,
    Anne


    Thanks, Anne Shashi
    Thursday, March 10, 2011 7:49 AM
  • Hi Chris,

    Can you please help me how to do this by giving an example. Please do the needful.

    Thanks,

    Anne

     


    Thanks, Anne Shashi
    Thursday, March 10, 2011 7:53 AM
  •  

    Hi Anne

    Sure essentially you have a spreadsheet that looks something like this that contains your test flows where keywords and data are passed through processors and lead to common code (below in data Member;1 means go to sheet Member row 1 for data for that action)

    Hope this shows well (it's part of something I gave to Parasoft as an example & not real).

    FlowControl Keyword Data Options Expected
      KWD.Test.StartTest Login & Select Member    

    Client.AdminLogin

    ProcessSuccessful

    Client.Member.SelectMember Member;1 Set="flow2" ProcessSuccessful
      KWD.Test.EndTest      

    KWD.Test.StartTest Test 2 runs if select member failed - otherwise skips  
    flow2 Client.Member.SelectMember Member;2 Fail ProcessSuccessful

    KWD.Test.EndTest      

    Client.Logout

    ProcessSuccessful

     

    then member sheet will contain relevant data columns for the action to keep this simple only really SIN would be used here but obviously what's here is related to what you need.

     

    Comments SIN
    Active Member 123456789

    Then your code for handling SelectMember will read in the data and use it to complete the predefined action. It should likely be a part of a related class which inherits common function/implements ones like read from a data table. You should use a set of common functions to handle interactions with app objects here's an example of one of mine

     

          

     public static Status Set(HtmlEdit oEdit, String sValue, String sInfo)
        {
          Status oStatus = new Status();
    
          if (sValue.Equals("!DEFAULT!"))
          {
            GlobalVars.Logger.ReportEvent(GlobalVars.Done, "Skipping EditBox Entry " + sInfo, "Value is default no changes made");
            return oStatus;
          }
    
    
          try
          {
            oEdit.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);
    
            oEdit.Text = sValue;
    
            GlobalVars.Logger.ReportEvent(GlobalVars.Done, "Set Edit Value " + sInfo, "Set Value [" + sValue + "]");
          }
          catch (Exception e)
          {
            // a failure here doesn't imply a test failure just an object set failure (could be expected)
            GlobalVars.Logger.ReportEvent(GlobalVars.Done, "Couldn't set HtmlEdit " + sInfo, "Error Unable to set value [" + sValue + "] hit Exception [" + e.Message + "]");
            oStatus.Fail();
          }
    
          return oStatus;
    
        }
    

    Honestly there's more information than I can possibly share in a post here, you should be able to find some resources online. At the very least You're going to wind up committing to writing a methodology to process keywords, read your data from a source (most people use excel sheets), Interact with your application & determine the results of that interaction (both for individual actions like above, and larger actions being the keywords you write), and very likely generate your own results based on everything you did & saw (which in my opinion leads to much better results).

     

    If you need further information drop an e-mail and I'll see about contacting you, can't really spend much time doing this during the day.

    Friday, March 11, 2011 7:10 PM