Showing posts with label Automation Testing. Show all posts
Showing posts with label Automation Testing. Show all posts

Thursday, April 21, 2011

Software Automation Testing Benefits

1. Saves time during the test execution: The execution of an automation test case( test script) is faster compared to the manual execution of a test case.

2. Execution of tests in un-attended mode: Once the entire automation suite( the automated test cases of the manual test case suite) is reayd for the execution, the automation suite can be executed in an un-attended mode( human attendance is not required for the entire execution), if the framework is designed in such a way. You can use the human brain for better innovative testing to improve the productivity of the overall testing process.

3. Consistency of test execution: When you execute manual regression suite several times, it is a general human tendency that we get bored of executing the same test cases time and again and because of which we may miss to execute one or many steps which may finally lead to an undetected bug!!! But, if you execute the automation suite, may be for 1 time or 100 times, it executes with the same efficiency and effectiveness.

4. Reducing cycle time of regression test cycles.

5. Data Driven Testing: This feature helps to parameterize the data in the script. This helps to get rid of hard coding of the values required for the test. Also, this feature helps in the concept of Retesting i.e, re-execution of the test/functionality with multiple sets of input data.

6. Coverage: Test coverage can be increased with the help of Automation. In real-time, testers have very less time to test n number of features. This makes the testers limit their scope in testing the application/products by determining the priority of the feature/functionality to be tested. But, that limitation can be overcome to a great extent with the help of automation.

With the above benefits of automation, automation has actually become a part of the entire life project life cycle and more importantly Automation life cycle has become an important subset of the entire Test life cycle. To reap good benefits from Test Automation to the entire project, you need to have good planning and coordination from the Development team, Manual Testing team and the Automation team.

Functional Test Automation Life Cycle

Functional Test Automation life cycle Methodology comprises 11 main phases:

1. Decision to automate testing: it is not that, directly we can kick-start automation for any project/AUT. The Test Manager and client has to take the deicison on whether to go for Test Automation or not. First, the need for Test Automation for the current project has to be determined considering the current status and future plan of the project. During that phase a Cost-Benefit Analysis has to be performed, during which the ROI(Return-On-Investment) has to be calculated and when the ROI is positive and considerable in acceptable time frame, the automation for the project can be given a nod.

2. Acquisition of Testing Tool: Once the decision has been made to go for automation, then the tool to automate the manual test cases has to be decided based on analysis of all the available tools in the market. There are several factors to consider like capability of the tool, compatability of the tool with the application, cost and ease of automation- design, execution and maintenance. If the tool is an easy to learn one then the aspect of "Availability of skilled resources" which we discussed earlier can be waived off as the available resources can be trained to make them skillful to work on the project.

3. Automation test planning: Once the Automation and tool are decided, the most important phase is the Test Planning Phase. This is the phase where the Test Manager/Automation Lead along with the client, has to plan on how to automate, what to automate, when to automate and who to automate. This phase also included the plan for the creation of Automation framework. The framework needs to be designed based on the need and scope of the project.

4. Set-up the automation environment: When the plan is ready, then the environment needs to be setup. This includes several activities like creating the application environment for automation similar to Dev-Environment and QA-environment. Sometimes due to budget/ any other constraint, a separate application environment for automation may not be available. In such cases, the QA-environment is used for automation. But, it is always a best practice to create a separate test data for automation so as not to interfere with regular manual testing activities. This phase also involves the formation of the team, necessary trainings and making the required test wares available.

5. Design the Automation framework: The automation framework is designed in this phase so as to carry on the automation script development, integration, execution and maintenance activities at ease.

6. Design/development of test scripts: Automation scripts are created in this phase/

7. Review and rework of test scripts: This is one of the most important phases, which is neglected by many. Each and every test script has to be reviewed with the help of an optimal checklist and by entering the review comments in a pre-defined review template. Once the review is completed, appropriate rework needs to be done implementing the review comments.

8. Integration of test scripts: All the scripts created by the Automation team are integrated in order to be executed during the execution phase.

9. Execution of test scripts: Test scripts are executed in this phase either by the Automation team or the manual testers.

10. Analysis of test results: Test results are analysed after execution.

11. Enhancement of test scripts(Maintenance Phase): Some of the test scripts may need to be updated depending on the change in the functionality for a particular version/build/release of the application and sometimes test scripts may need to added if new functionality is included in the application. Again, review comes into picture, followed by rework and so on.

QTP Test Object Model

Test object Model is a set of object types or Classes that QuickTest uses to represents the objects in our application.
A test object class comprises of a list of properties that can individually (uniquely) identify objects of that class and a set of appropriate methods that QuickTest can record for it.
A test object is an object that QuickTest creates in the test to correspond to (represent) the actual object in the application. QuickTest uses the stored information about the object during the run session to identify and check the object. A run-time object is the real (actual) object in the application or Web site on which methods are performed during the run session.
Properties and methods of objects:
The property set for each test object is created and maintained by QuickTest. The property set for each run-time object is created and maintained by the object architect (creator) (Microsoft for Internet Explorer objects, Netscape for Netscape objects).
Similarly, methods of test objects are methods that QuickTest recognizes and records when they are executed (performed) on an object while we are recording, and that QuickTest executes when the test or component runs. Methods of Run-time object are the methods of the object in theapplication as defined by the object architect (creator). We can access and execute run-time object methods using the Object property.
Some important points to remember about methods and properties :

  • Each test object method we execute (perform) while recording is recorded as a separate step in the test. When we run the test, QuickTest executes (performs) the recorded test object method on the run-time object.

  • Properties of test object are captured from object while recording. QuickTest uses the values of these properties to identify runtime objects in the application during a run session.

  • Property values of objects in the application may change .To make the test object property values match the property values of the run-time object, we can modify test object properties manually while designing the test or component or using SetTOProperty statements during a run session. We can also use regular expressions to identify property values.

  • We can view or modify the test object property values that are stored with the test or component in the Object Properties or Object Repository dialog box.

  • We can view the syntax of the test object methods as well as the run-time methods of any object on our desktop using the Methods tab of the Object Spy.

  • We can retrieve or modify property values of the TEST OBJECT during the run session by adding GetTOProperty and SetTOProperty statements in the Keyword View or Expert View. We can retrieveproperty values of the RUNTIME OBJECT during the run session by adding GetROProperty statements. If the available test object methods or properties for an object are not sufficient or they do not provide the functionality we need, we can access the internal methods and properties of any run-time object using the Object property. We can also use the attribute object property to identify Web objects in the application according to user-defined properties.

  • Descriptive Programming QTP Tutorial

    Whenever you record on any object using QTP, QTP adds the test object to the Object Repository. While running a test, QTP finds the object in the Object Repository and uses the stored test object’s description to identify the object in your application/website. Only after the object is found in the Object Repository, QTP can perform methods on those objects.
    We can also instruct QTP to perform methods on objects without referring to the Object Repository. This is possible with the help of Programmatic descriptions or descriptive programming.
    This implies that descriptive programming is very helpful if you want to perform an operation on an object that is not stored in Object Repository.
    Descriptive Programming is also useful to perform the same operation on several objects with certain matching properties e.g. suppose there are 8 check boxes on a web page with names as chk_1, chk_2 and so on. So it’s not a good idea to put these in an Object Repository. With the help of Descriptive Programming you can Set these check boxes ON or OFF according to your application needs.
    If you are dynamically creating test objects during the run session then also Descriptive Programming goes a long way to help you. Suppose in a web site you have to generate a list of all the customer's email addresses, who brought iPhone from you, based on the geographical information you provided and then after the email addresses are provided as checkboxes you have to send a rebate letter to them. You don't know how many check boxes will be there based on the geographical information you provided. So in this case, you can use a Descriptive programming to instruct QTP to perform a Set "ON" method for all objects that fit the description: HTML TAG = input, TYPE = check box.
    Descriptive programming can be done in two ways:
    Static: We provide the set of properties and values, that describe the object, directly.
    Dynamic: We have to add a collection of properties and values to a description object and then provide the statement with the description object's name.
    Static is easier but Dynamic provides more power, efficiency, and flexibility.
    We will see examples of both static and dynamic type of descriptive programming in QTP.
    First let’s take a look at Static:
    This below example uses Descriptive Programming to open Flight Application and does not use object repository at all. So one of the other advantages is you can copy this script and Run this from any other machine (other than on which it was created) and it is supposed to work fine.
    For this time just read the script and move on, you will better understand it as you read more.
    [ I have given Example 1a's recorded version (which uses Object Repository)in Example 1b just for your comparison of the two so that you can better understand both ]
    Example 1a: uses DP
    We can describe the object directly by specifying property: =value pairs.
    SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe"
    window("Title:=Login").WinEdit("AttachedText:=Agent Name:").Set "sachin"
    window("Title:=Login").WinEdit("AttachedText:=Password:").Set "mercury"
    window("Title:=Login").winbutton("Text:=OK").Click
    window("Title:=Flight Reservation").close

    Examle 1b: uses OR
    SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
    Dialog("Login").WinEdit("Agent Name:").Set "sachin"
    Dialog("Login").WinEdit("Agent Name:").Type micTab
    Dialog("Login").WinEdit("Password:").SetSecure "476a9c021bc5a7422cf5a84ad08503823abcbaae"
    Dialog("Login").WinButton("OK").Click
    Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"

    Note: When using programmatic descriptions from a specific point within a test object hierarchy, you must continue to use programmatic descriptions from that point onwards within the samestatement . If you specify a test object by its object repository name after other objects in the hierarchy have been specified using programmatic descriptions, QTP cannot identify the object.
    For example, you can use the following statement since it uses programmatic descriptions throughout the entire test object hierarchy:
    Browser("Title:=Mercury Tours").Page("Title:=Mercury Tours").WebEdit("Name:=Author", "Index:=3").Set "Testing"
    Above line uses Descriptive Programming for all objects like Browser, Page, WebEdit.
    You can also use the statement below, since it uses programmatic descriptions from a certain point in the description (starting from the Page object description):
    Browser("Mercury Tours").Page("Title:=Mercury Tours").WebEdit("Name:=Author", "Index:=3").Set "Testing"
    Above line uses Object Repository for Browser object and Descriptive Programming for Page and WebEdit.
    However, you cannot use the following statement, since it uses programmatic descriptions for the Browser and Page objects but then attempts to use an object repository name for the WebEdit test object:
    Browser("Title:=Mercury Tours").Page("Title:=Mercury Tours"). WebEdit("Author").Set "Testing"
    QTP tries to locate the WebEdit object based on its name, but cannot locate it in the repository because the parent objects were specified using programmatic descriptions.
    If the same programmatic description is being used several times then we can assign the object to a variable:
    E.g. in the above Example 1a script, window("Title:=Login") is being used several times so we do this:
    Set var = window("Title:=Login")
    SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe"
    var.WinEdit("AttachedText:=Agent Name:").Set "
    Testing"
    var.WinEdit("AttachedText:=Password:").Set "mercury"
    var.winbutton("Text:=OK").Click
    window("Title:=Flight Reservation").close

    Or
    We can use 'With & End With' Statement like below:
    SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe"
    With window("Title:=Login")
    .WinEdit("AttachedText:=Agent Name:").Set "
    Testing"
    .WinEdit("AttachedText:=Password:").Set "mercury"
    .winbutton("Text:=OK").Click
    End with
    window("Title:=Flight Reservation").close

    Now let’s take a look at the dynamic type:
    Understand it like this – A Property Object is a property name and value. We use Description object to return a Properties collection object containing a set of Property Objects. Then only in place of an object name, returned properties collection, can be specified in a statement.
    For creating Properties collection "Description.Create" statement is used.
    Set Myvar = Description.Create() Once Property Object (Myvar) is created, statements to add, edit, remove and retrieve properties and values to or from properties objects can be entered during the run time.
    Lets take a complete example of this: [these extra values (height & width) are not important in our example. Our example can run without height and widthproperties. I have just added those in order to make you understand this]
    SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe"
    window("Title:=Login").WinEdit("AttachedText:=Agent Name:","height:=20","width:=119" ).Set "
    Testing"
    window("Title:=Login").WinEdit("AttachedText:=Password:").Set "mercury"
    window("Title:=Login").winbutton("Text:=OK").Click
    window("Title:=Flight Reservation").close

    Now modifying the above script using Description.Create.
    Set myvar= description.Create()
    myvar("AttachedText").value="Agent Name:"
    myvar("height").value=20
    myvar("width").value=119
    SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe"
    window("Title:=Login").WinEdit(myvar ).Set "
    Testing"
    window("Title:=Login").WinEdit("AttachedText:=Password:").Set "mercury"
    window("Title:=Login").winbutton("Text:=OK").Click
    window("Title:=Flight Reservation").close

    Retrieving child objects in Descriptive Programming:
    There is a ChildObjects method which can be used to get all objects located within a specific parent object or only those that match some criteria for programmatic description. In short we first of all need to create a description and then use a particular syntax to retrieve all child objects that match that description and manipulate them according to our own wish.
    I will straightway show you an example of how to do this:
    Make sure that Flight Reservation window is open (Start- Programs- QuickTest Professional- Sample Applications- Flight). In this Flight reservation window go to File- Open Order.
    We will use this childobjects method to count the checkboxes in this 'Open Order' dialogbox.In the below script childobjects method is being applied to dialog object and childobjects method uses mydescription property object we created.
    Set mydescription=Description.Create()
    mydescription("Class Name").value="WinCheckBox"
    Set Checkboxes = window("text:=FLight Reservation").dialog("text:=Open Order").ChildObjects(mydescription)
    a=Checkboxes.count
    msgbox(a)

    Just try to understand the above code. This is just an example, in real life you can use this count in some kind of loop.
    Creating checkpoints programmatically:
    Run-time value of a specified object property can be compared with expected value of that property by using programmatic description.
    Descriptive programming checks are helpful for the object whose properties you want to check but the object is not stored in Object Repository.
    I will show a small example here which checks if the "Flights.." button in Flight Reservation window is enable or disable. I have used a message box to show whether it is enable or disable, you can use the Report.ReportEvent Statement to send the results to the result window of QTP.
    For the below script make sure that Flight reservation window is open:
    a=window("Title:=Flight Reservation").winbutton("Text:=FLIGHT").GetROProperty("enabled")
    msgbox (a)
    If a = True Then
    msgbox ("button is enable")
    else
    msgbox ("button is disable")
    End If

    In the above script GetROProperty method is being applied to 'Flight..' button to check the 'enable' property of the button.
    [you can see an object's properties and methods from QTP help. Definitely there are other ways also to get these].
    DP is also useful in case of programming WebElement objects (A WebElement is a general web object which can represent any web object.)
    As an example, just open the website (http://newtours.demoaut.com/) and make sure the cursor is in the “User Name” text box and write the following line in the Expert View of new test:
    browser("title:=Welcome: Mercury Tours").page("title:=Welcome: Mercury Tours").webelement("name:=password","index:=2").Click
    It will just click the “Password” text box which just highlights that text box and places the mouse cursor in that box.
    For all the methods and properties of WebElement object please refer QTP User Guide.
    Index property
    Index property is useful to identify a test object uniquely. QTP also, while learning an object, can assign a value to test object’s index property to uniquely identify it. Index property values are specific to an object and also the value is based on the order in which the object appears in the source code.
    The value starts with 0.
    If you use Index:=1 with WebEdit test object, QTP will search for the second WebEdit object on a web page.
    As an example, just open the website (http://newtours.demoaut.com/) and write the following line in the expert view of new test:
    browser("title:=Welcome: Mercury Tours").page("title:=Welcome: Mercury Tours").WebEdit("Index:=1").Set "hello"
    This will write “hello” in the “Password” text box. In the above line if you do Index:=0 then “hello” will be written in the “User Name” text box.
    On the other hand if you use Index:=2 to describe a WebElement object, QTP will search for the third object on the page (it can be any, regardless of type) because WebElement object is general object that applies to all objects.
    Last but not the least SystemUtil object
    SystemUtil object allows you to open and close application by writing its code manually in the Expert view of QTP.
    Below example shows how to open or close a Notepad using code:
    systemutil.Run "Notepad.exe"
    wait(3)
    SystemUtil.CloseProcessByName("Notepad.exe")

    This example uses Run and CloseProcessByName methods to open and close the application (Notepad). Instead of closing the Notepad with CloseProcessByName method, we can use the below line also which is mostly used.
    window("title:=Untitled - Notepad").Close
    For opening the application we can use complete paths also e.g.
    systemutil.Run "C:\Program Files\Internet Explorer\iexplore.exe"
    This opens an Internet explorer.