Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Showing posts with label interview questions in qtp. Show all posts
Showing posts with label interview questions in qtp. Show all posts

QTP Interview Questions

Interview Questions in QTP ?
1. What is QTP ?
       QTP is an automation testing tool employed for functional test automation. It supports all the types of automation framework, such as keyword, data, hybrid, functional and the simplest of all record and playback.

2) What are the types object Repositories in QTP.
       QTP Supports 2 types of Object Repository

1) Shared Object Repository (also called Global), having extension as .tsr

2) Per-Action Object Repository, (also called Local), having extension as .mtr

Per-Action Object Repository is used by default. The extension for Per-Action repository is ".mtr" .
Shared Object Repository is preferable while dealing with dynamic objects which are called in multiple tests. The extension is ".tsr"

3) Can we call QTP test from another test using scripting. Suppose there are multiple tests and I want to call these tests in a main script. Is this possible in QTP? 
       Yes.  You can call multiple or even more scripts in your tests.For this, first you will need to make the Actions in the corresponding scripts re-usable.Then from the destination script you can make calls to these re-usable actions.

4) What is action split and the purpose of using this in QTP?
        Action split is to divide an existing action into two parts. The purpose is to divide actions based on their functionality to improve code re-use.

5) How will you handle Java tree in QTP ?
        Foremost you will select Java Add - In and launch QTP. Next step record operations on the Java Tree. If you face an issue while recording, you can select Tools > Object Identification > Java, tree object and make changes in mandatory and assistive properties to enable identification.
Tip: You can base you answer on similar lines for any other object of any environment. For example : If the question is how will check SAP checkbox , You say , first I will select SAP Add in ... and so on.

6) Explain how QTP identifies object ?
        QTP identifies any GUI Object based on its corresponding properties.  While recording, QTP will identify and store peculiar properties (as defined in the Object Identification settings) in the object repository of the GUI object . At run-time, QTP will compare the stored property values with the on-screen properties, to uniquely identify the GUI object.


7) How many types of recording modes in QTP? Which will be used when ?
         QTP supports 3 types of recording modes
1. Normal mode also called Contextual
2. Low-level recording mode
3.Analog mode

Normal Mode: It is the default recording mode and takes full advantage of QTP's Test Object Model. It recognizes objects regardless of their position on -screen. This is the preferred mode of recoding and is used for most of the automation activities.
Low-level recording mode: This mode records the exact x,y co-ordinates of your mouse operations. It is helpful in testing hashmaps. It is useful for recording objects not identified by normal mode of QTP.
Analog mode: This mode records exact mouse and keyboard "movements" you perform in relation to the screen / application window. This mode is useful for the operation such as drawing a picture, recording signature., drag and drop operations.



8) How will you  call from one action to another action ?
         We can call an action in 2 ways
1) Call to copy of Action. - In this ,the Action Object Repository , Script and Datable will be copied to the destination Test Script.
2) Call to Existing Action. - In this,  Object Repository , Script and Datable  will NOT be copied but a call (reference) would be made to the Action in the source script.

9) What are Virtual Objects?
            Your application may contain objects that behave like standard objects but are not recognized by QTP. You can define these objects as virtual objects and map them to standard classes, such as a button or a check box. QTP emulates the user's action on the virtual object during the run session. In the test results, the virtual object is displayed as though it is a standard class object.
For example, suppose you want to record a test on a Web page containing a bitmap that the user clicks. The bitmap contains several different hyperlink areas, and each area opens a different destination page. When you record a test, the Web site matches the coordinates of the click on the bitmap and opens the destination page.
To enable QTP to click at the required coordinates during a run session, you can define a virtual object for an area of the bitmap, which includes those coordinates, and map it to the button class. When you run a test, QTP clicks the bitmap in the area defined as a virtual object so that the Web site opens the correct destination page.

10) How to perform Cross platform testing and Cross browser testing using QTP? Can u explain giving some example?
You will need to create separate Actions which take care of different OS and Browsers
Cross Platform Testing:

Using the Built in Environment Variable you can dig up the OS information.
Eg. Platform = Environment("OS"). Then based on the Platform you need to call the actions which you recorded on that particular platform.

Cross Browser Testing:

Using this code  Eg. Browser("Core Values").GetROProperty("version") you can extract the Browser and its correspondin version. Ex: Internet Explorer 6 or Netscape 5. Based on this value you call the actions which are relevant to that browser.

11) What is logical name of the object?
           Logical name is a name  given by  QTP while creating an object in the repository to uniquely identify it from other objects in the application. This name would be used by the QTP to map the object name in script with its corresponding description in the object repository. Ex: Browser("Browser").Page("Viplav15") Here Viplav15 is the logical name of the object.

12) What is descriptive programming?
            Typically ,an object and its properties must be recorded in the Object Repository to enable QTP to perform action s on it. 
Using descriptive programming , you do not store the object and its property values in the Object repository but mention the property value pair directly in the script.
The idea behind descriptive programming is not bypass the object repository but help recogonize dynamic objects.


13)What are the properties you would use for identifying a browser & page when using descriptive programming ?
        You can use the name property
ex: Browser("name:="xxx"").page("name:="xxxx"").....
OR

We can also use the property "micClass".
ex: Browser("micClass:=browser").page("micClass:=page")....

14)Can we record an application running on a remote machine using QTP ? 
        Yes .you can record remote application provided you are accessing application through the   browser not via remoter like citrix.
If you are still unable to record it is advisable install QTP and application, on the same machine

15) Explain the keyword CreateObject with an example.
         Creates and returns a reference to an Automation object
SYNTAX: CreateObject(servername.typename [, location])
Arguments
servername: Required. The name of the application providing the object.
typename :  Required. The type or class of the object to create.
location :  Optional. The name of the network server where the object is to be created.
Example : Set IE = CreateObject("InternetExplorer.Application")

16) Can you switch between Per-Action and Shared Object Repository ? If yes how ?
          Yes .We can switch. Go to Test--->Settings--->Resources. Here  you have an option to choose repositories.

17) What is Object Spy ? How to Use it ?
           Object Spy helps in determining the run & test time object properties & methods of the application under test.
You can access object spy directly from the toolbar or from the Object Repository Dialog Box.
It is very useful during Descriptive Programming


18) When ordinal identifiers alone can make an object unique then why they are not given top priority? Why it is first mandatory and next assistive. Why we cannot go for ordinal identifiers directly?
Consider the following -
a) If two objects are overlapped on each other than location based object recognition will fail.
b) If only index based recognition is used your script will work but script execution time will increase.
Hence mandatory and assistive properties are used.

19) What is the file extension of the code file in QTP?
Code file extension is script.mts

20) Explain in brief about the QTP Automation Object Model.
QTP Automation Object model deals with Automation of QTP itself. Almost all configuration and functionality provided by QTP is represented by QTP's Automation Object Model . Almost all dialog boxes in QTP have a corresponding automation object which can set or retrieved using the corresponding properties or methods in the Automation Object Model.QTP Automation Objects can be used along with standard VB programming elements like iterative loops or conditional statements to help you design a script of choice.

21) What is the use of Text output value in QTP?
        Text Output values enable you to capture text appearing on the application under test during run-time.
If parameterized, text output values will capture values appearing in each iteration which would be stored in the run-time data table for further analysis.

22) What is Step Generator?
        Step Generator enables use to Add Test Steps in your script. Using step generator you can add steps to your script without actually recording it.

23) How to make QTP understand the difference amongst the  same type of objects .Suppose there are 5 check boxes in a page and I have to choose the 2nd one, how to do that through script?
         You can use ordinal identifiers like index along with a little descriptive programming for object recognition.

24) What is Test Fusion Report ?.
         Test Fusion Report , displays all aspects of a test run and is organized in a Tree format.
It gives details of each step executed for all iterations.
It also gives Run-time data table, Screen shots and movie of the test run if opted.

25) How can you handle exceptions in QTP?
         In QTP Exceptional handling is done by using
a. Recovery Scenarios.
b. Using “On Error” statement
In Recovery scenario you have to define.
1. Triggered Events.
2. Recovery steps.
3. Post Recovery Test-Run.
At Script Level you can use the On Error Resume Next and On Error Go to 0 statement.

     
26) What are the types of environment variables in QTP ?
           Environment variables in QTP are of three types:
1) Built-in (Read only)
2) User-defined Internal (Read only)
3) User-defined External (Read/Write)

You Set the Environment Variable  using the following syntax 
Environment.Value( "name") = "Viplav15"
You can Retrieve the Environment Variable using following syntax
Environment.Value("name") -- This will retrun name as Viplav15
Environment.Value("OS")  -- This will return your system OS

27) What is the Difference between Bitmap Check point & Image Check point?
                Bitmap checkpoint does a pixel to pixel comparison of an image or part of an image.
Image checkpoint does do a pixel to pixel comparison but instead compare image properties like alt text , destination url etc.

28) What is the difference between functions and actions in QTP?
          Actions have their own Object Repository & Data Table. Actions help make your Test modular and increase reuse. Example: You can divide your script into Actions based on functionality like Login, Logout etc. Functions is a VB Script programming concept and do not have their own Object Repository or Data Table. Functions help in re-use of your code. Ex:  You can create a Function in your script to concatenate two strings.

29) What is keyword view and Expert view in QTP? -
          Keyword View is an icon based view which shows test steps in tabular format. It also automatically generates documentation for the test steps.
Expert View gives the corresponding VB Script statement for every test step in the Keyword view.

30)  Explain QTP Testing process? -
          Quick Test testing process consists of 6 main phases:
1)  Create your test plan - This is preparatory phase where you identify the exact test steps, test data and expected results for you automated test. You also identify the environment and system configurations required to create and run your QTP Tests.
2) Recording a session on your application - During this phase , you will execute test steps one by one on your AUT ,and QTP will automatically record corresponding VB script statements for each step performed.
3) Enhancing your test - In this stage you will insert checkpoints , output values , parameterization , programming logic like if…else loops to enhance the logic of your test script.
4) Replay & Debug - After enhancements you will replay the script to check whether its working properly and debug if necessary.
5) Run your Tests - In this phase you will perform the actual execution of your Test Script.
6) Analyzing the test results - Once test run is complete, you will analyze the results in the Test Fusion report generated.
7) Reporting defects - Any incidents identified needs to be reported. If you are using Quality Center , defects can be automatically raised for failed tests in QTP.

31) What are the different types of Test Automation Frameworks ?
            The types of Automation Frameworks are -
1) Linear Scripting - Record & Playback
2) The Test Library Architecture Framework.
3)The Data-Driven Testing Framework.
4)The Keyword-Driven or Table-Driven Testing Framework.
Learn more about Test Automation Frameworks.

32) How will you check a web application for broken links using QTP?
            You can use the Page Checkpoint which gives a count of valid/invalid links on a page.

33) What is a Run-Time Data Table? Where can I find and view this table?
             Data like parameterized output , checkpoint values , output values  are stored in the Run-time Table. It is an xls file which is stored in the Test Results Folder.  It can also be accessed in the Test Fusion Report.

34) What is the difference between check point and output value.
            Check point is a verification point that compares a current value for a specified property with the expected value for that property. Based on this comparison, it will generate a PASS or FAIL status. 
An output value is a value captured during the test run and can be stored in a specified location like the  Datable or even a variable. Unlike Checkpoints, no PASS/FAIL status is generated.

34) How would you connect to database using vbscript ? 
      To connect to the database you must know
a) connection string of your server
b) username
c) password
d) DNS name
You can code the database connectivity command directly or you can use the SQL Query tool provided by QTP.

35) What is QTP batch testing tool?
         You can use the Batch testing tool to run multiple scripts. Once the scripts are added in the tool , it  will automatically open the scripts and start executing them one after the other.

36) What are the drawbacks of QTP?
          As of QTP version 10
1) Huge Tests in QTP consume lots of memory and increase CPU utilization.
2) Since QTP stores results in HTML file (and not txt) the result folder sometimes becomes big.

37) What is an Optional Step ?
          A step when declared optional is not mandatory to be executed. If the corresponding GUI object is present, QTP performs the operation on it. If the GUI object is not present, QTP bypasses the optional step and proceeds to execute the next step.

38) What  is Reporter.ReportEvent ?
          Reporter.Reportvent is standard method provided by QTP to send custom messages to the test results window.
Syntax
Reporter.ReportEvent EventStatus, ReportStepName, Details [, ImageFilePath]
where     
EventStatus = 0 or micPass
                    1 or micFail
                    2 or micDone
                    3 or micWarning
 Results can assume any status like Pass , Fail , Warning etc. You can also send screenshot to the test results window.

39) How will you  declare a variable in QTP ?
          You declare using a DIM keyword. You assign value to the variable using the SET keyword.
Ex.
Dim temp 'Will declare the temp variable
Set  temp = 20 ' Will assign a value 20 to temp.

39) What is GetRoProperty ?
         GetRoProperty is a standard method provided by QTP to fetch property values of a run -time object.

40) What is smart Identification?
         Typically, if even one of the on-screen object property does not match the recorded object property. The test fails.
In smart identification, QTP does not give an error if the property values do not match, but uses Base filter and Optional Filter properties to uniquely identify an object. In Smart identification, if a property value does not match the script does not fail but it proceeds ahead to compare the next property. Smart identification can be enabled in Object Identification Dialog box.
Learn more about SMART Identification

41) How would you export a Script from one PC to another in QTP ?
          We can make use of the "Generate Script" function available in Object Identification, Test Settings and Tools/Options tab to create a zip of the script at the source computer. These zip files then can be imported into QTP at the destination computer.

42) Can launch two instances of QTP on the same machine ?
           No. QTP does not permit for it, though some of the other tools do have such a facility availed in them, such as most of the microsoft owned tool, starting from MPP,MSWORD, excel bla bla bla.

43) Give the syntax to import/export xls into QTP.
           DataTable.ImportSheet "..\..\TestData\Input.xls",1,dtGlobalSheet
DataTable.ExportSheet "..\..\Results\Output.xls","Global"

44) What is SetToProperty ?
          SetToProperty changes property of an object stored in the Object Repository. However these changes are not permanent.

45) What is the standard timing delay for web based application in QTP ?
         The standard delay is 60 seconds. This is can be changed in Test Settigns.

46) What is the Action Conversion Tool ?
          It is an in-built tool provided by QTP to convert Actions into Business Process Components.

47) What is the extension for a function library ?
         The extension is  '.QFL'

48) If the Global Data sheet contains no data and the Local Datasheet contains two rows of data, how many times will the test iterate?
         The test will iterate only once - global iteration.

49)  What factors affect bitmap checkpoints ?
         Bitmap checkpoints are affected by screen resolution and image size.

50)  What is Accessibility Checkpoint?
        World Wide Web Consortium (W3C) came up with some instructions and guidelines for Web-based technology and information systems to make it easy for the disabled to access the web. For example the standards make it mandatory to have an 'alt text' for an image. So a blind person who is accessing the website, will use text - to -speech converters and atleast understand what the image is about if not see it. All these standards are checked by Accessibility Checkpoints.

For basic approach
Common questions on automation testing



For gaining more insights in the automation using QTP log on to below url :

Automation Testing Using QTP

Interview Questions On QTP

Automation testing has been the key industry driver in terms of quality assurance to be provided for any software. Manual testing is very high in terms of cost and hence as the product matures, the expectation of clients from the service providers is to reduce the cost to an optimized limit. That is the place wherein automation testing comes into place. As a result any experience QA professional is expected to be adept in doing the same. Below are outlined some of the interview questions in Quick Test Pro.


1. What are the features and benefits of Quick Test Pro(QTP)?
1. Key word driven testing
2. Suitable for both client server and web based application
3. VB script as the script language
4. Better error handling mechanism
5. Excellent data driven testing features

2. How to handle the exceptions using recovery scenario manager in QTP?
You can instruct QTP to recover unexpected events or errors that occurred in your testing environment during test run. Recovery scenario manager provides a wizard that guides you through the defining recovery scenario. Recovery scenario has three steps
1. Triggered Events
2. Recovery steps
3. Post Recovery Test-Run

3. What is the use of Text output value in QTP?
Output values enable to view the values that the application talks during run time. When parameterized, the values change for each iteration. Thus by creating output values, we can capture the values that the application takes for each run and output them to the data table.

4. How to use the Object spy in QTP 8.0 version?
There are two ways to Spy the objects in QTP
1) Thru file toolbar: In the File ToolBar click on the last toolbar button (an icon showing a person with hat).
2) Thru Object repository Dialog: In Objectrepository dialog click on the button "object spy…" In the Object spy Dialog click on the button showing hand symbol. The pointer now changes in to a hand symbol and we have to point out the object to spy the state of the object. If at all the object is not visible or window is minimized then hold the Ctrl button and activate the required window to and release the Ctrl button.

5. What is the file extension of the code file and object repository file in QTP?
File extension of
Per test object rep: filename.mtr
Shared Object rep: filename.tsr
Code file extension id: script.mts

6. Explain the concept of object repository and how QTP recognizes objects?
Object Repository: displays a tree of all objects in the current component or in the current action or entire test( depending on the object repository mode you selected).
we can view or modify the test object description of any test object in the repository or to add new objects to the repository.
Quicktest learns the default property values and determines in which test object class it fits. If it is not enough it adds assistive properties, one by one to the description until it has compiled the unique description. If no assistive properties are available, then it adds a special Ordianl identifier such as objects location on the page or in the source code.

7. What are the properties you would use for identifying a browser and page when using descriptive programming?
"name" would be another property apart from "title" that we can use. OR
We can also use the property "micClass".
ex: Browser("micClass:=browser").page("micClass:=page")

8. What are the different scripting languages you could use when working with QTP?
You can write scripts using following languages:
Visual Basic (VB), XML, JavaScript, Java, HTML

9. Tell some commonly used Excel VBA functions.
Common functions are:
Coloring the cell, Auto fit cell, setting navigation from link in one cell to other saving

10. Explain the keyword createobject with an example.
Creates and returns a reference to an Automation object
syntax: CreateObject(servername.typename [, location])
Arguments
servername:Required. The name of the application providing the object.
typename : Required. The type or class of the object to create.
location : Optional. The name of the network server where the object is to be created.

11. Explain in brief about the QTP Automation Object Model.
Essentially all configuration and run functionality provided via the QuickTest interface is in some way represented in the QuickTest automation object model via objects, methods, and properties. Although a one-on-one comparison cannot always be made, most dialog boxes in QuickTest have a corresponding automation object, most options in dialog boxes can be set and/or retrieved using the corresponding object property, and most menu commands and other operations have corresponding automation methods. You can use the objects, methods, and properties exposed by the QuickTest automation object model, along with standard programming elements such as loops and conditional statements to design your program.

12. How to handle dynamic objects in QTP?
QTP has a unique feature called Smart Object Identification/recognition. QTP generally identifies an object by matching its test object and run time object properties. QTP may fail to recognize the dynamic objects whose properties change during run time. Hence it has an option of enabling Smart Identification, wherein it can identify the objects even if their properties changes during run time.
Check out this:
If QuickTest is unable to find any object that matches the recorded object description, or if it finds more than one object that fits the description, then QuickTest ignores the recorded description, and uses the Smart Identification mechanism to try to identify the object.
While the Smart Identification mechanism is more complex, it is more flexible, and thus, if configured logically, a Smart Identification definition can probably help QuickTest identify an object, if it is present, even when the recorded description fails.

The Smart Identification mechanism uses two types of properties:
Base filter properties – The most fundamental properties of a particular test object class; those whose values cannot be changed without changing the essence of the original object. For example, if a Web link's tag was changed from to any other value, you could no longer call it the same object. Optional filter properties – Other properties that can help identify objects of a particular class as they are unlikely to change on a regular basis, but which can be ignored if they are no longer applicable.

13. What is a Run-Time Data Table? Where can I find and view this table?
In QTP, there is data table used, which is used at runtime.
-In QTP, select the option View->Data table.
-This is basically an excel file, which is stored in the folder of the test created, its name is Default.xls by default.

14. How does Parameterization and Data-Driving relate to each other in QTP?
To data driven we have to parameterize. i.e. we have to make the constant value as parameter, so that in each interaction(cycle) it takes a value that is supplied in run-time data table. Through parameterization only we can drive a transaction (action) with different sets of data. You know running the script with the same set of data several times is not suggested, and it's also of no use.

15. What is the difference between Call to Action and Copy Action.?
Call to Action: The changes made in Call to Action, will be reflected in the original action (from where the script is called). But where as in Copy Action , the changes made in the script ,will not effect the original script(Action).

16. Explain the concept of how QTP identifies object.
During recording qtp looks at the object and stores it as test object. For each test object QT learns a set of default properties called mandatory properties, and look at the rest of the objects to check whether this properties are enough to uniquely identify the object. During test run, QTP searches for the run time objects that matches with the test object it learned while recording.

17. Differentiate the two Object Repository Types of QTP.
Object repository is used to store all the objects in the application being tested.
Types of object repository: Per action and shared repository.
In shared repository only one centralized repository for all the tests. where as in per action for each test a separate per action repository is created.

18. What the differences are and best practical application of Object Repository?
Per Action: For Each Action, one Object Repository is created.
Shared: One Object Repository is used by entire application.

19. Explain what the difference between Shared Repository and Per Action Repository
Shared Repository: Entire application uses one Object Repository , that similar to Global GUI Map file in WinRunner.
Per Action: For each Action, one Object Repository is created, like GUI map file per test in WinRunner.

20. Have you ever written a compiled module? If yes tell me about some of the functions that you wrote.
Sample answer (You can tell about modules you worked on. If your answer is Yes then You should expect more questions and should be able to explain those modules in later questions): I Used the functions for Capturing the dynamic data during runtime. Function used for Capturing Desktop, browser and pages.

21. Can you do more than just capture and playback?
Sample answer (Say Yes only if you worked on): I have done Dynamically capturing the objects during runtime in which no recording, no playback and no use of repository is done AT ALL.
-It was done by the windows scripting using the DOM(Document Object Model) of the windows.

22. How to do the scripting. Are there any inbuilt functions in QTP? What is the difference between them? How to handle script issues?
Yes, there's an in-built functionality called "Step Generator" in Insert->Step->Step Generator -F7, which will generate the scripts as you enter the appropriate steps.

23. What is the difference between check point and output value?
An output value is a value captured during the test run and entered in the run-time but to a specified location.
EX:-Location in Data Table[Global sheet / local sheet]

24. How many types of Actions are there in QTP?
There are three kinds of actions:
Non-reusable action – An action that can be called only in the test with which it is stored, and can be called only once.
Reusable action – An action that can be called multiple times by the test with which it is stored (the local test) as well as by other tests.
External action – A reusable action stored with another test. External actions are read-only in the calling test, but you can choose to use a local, editable copy of the Data Table information for the external action.

25. I want to open a Notepad window without recording a test and I do not want to use System utility Run command as well. How do I do this?
You can still make the notepad open without using the record or System utility script, just by mentioning the path of the notepad "( i.e. where the notepad.exe is stored in the system) in the "Windows Applications Tab" of the "Record and Run Settings window.

Browse through a lot of posts on Automation testing using QTP Qtp Testing



Selenium in Automation Testing

Let us start with some questions that Automated Testing environment should answer before delving into some serious  works.

1.What are the advantages of Selenium over QTP and Silk test?
Ans- The Greatest Advantage is that it is an Open Source free Tool. So cost wise it scores over other 2 tools. Other advantages I have explained in my third Answer.

2.Does it have any disadvantage?
Ans- One of the disadvantage which I felt is the lack of proper documentation. There are lots of features which we fail to utilize because of this. Also Support is limited compared to other paid tools and we have to  depend on forums and other people to solve our issues. Also Selenium can only be used for Web Based  Application.

3.How is it unique i.e, how does it stand out from the other automation tools?
Ans-Selenium testing suite is highly flexible. There are multiple ways to add functionality to Selenium framework to customize test automation. As compared to other test automation tools, it is
Selenium’s strongest characteristic. Selenium Remote Control support for multiple programming and scripting languages allows us to build any logic we need into our
automated testing and to use a preferred programming or scripting language of our choice. Also,  Selenium testing suite is an open source project where code can be modified and
enhancements can be submitted for contribution.

4.How flexible is the Selenium test suite?

Ans-Selenium Test Suite is highly flexible. For Java we may use Junit or  TestNG framework  for running suite. For C# we can use NUnit Framework.

5.And the last question would be why don't we use it in many project?
Ans- Lack of Experienced Resources with Selenium experience was one of the major concern. Quite a lot of application is not fully supported by Mozilla Browser writing of Test Scripts would have become difficult for few  scenarios.


 There are many Automation Testing Tools available, to name a few QTP, Silk Test, Selenium, Watir etc. Today I would like to share my experience with “Automation Testing Using Selenium”

About Selenium

Ø   Selenium is a OPEN SOURCE automation functional test tool developed by Thought Works.
Ø    Selenium is for web automation.
Ø    Selenium can be chosen to use its recording capabilities/you can edit the script .
Ø    Selenium tests run directly in any browser and supports any OS.
Ø    Selenium uses JavaScript to embed a test automation engine in browser
Ø    Selenium supports writing test in java,. NET, Perl, Python and Ruby.
Ø    Create regression tests to verify application functionality and user acceptance.

Components Of Selenium

Ø  Selenium IDE
Ø  Selenium RC
Ø  Selenium Core
Ø  Selenium Grid

Selenium IDE

Ø   Selenium IDE is implemented as Firefox extension.
Ø   Allows you to record, edit and debug test.
Ø   Test can be saved as HTML, Ruby scripts or any other format.
Ø   Options to assert the title of every page.
Ø    Debug and set breakpoint.
Ø   Easy record and playback.
Ø  Scripts written in SeIDE can be run in any Browser after creating a Suite for the Scripts


Installation of Selenium IDE

Ø   Install Mozilla Firefox browser
Ø   Download Selenium IDE 1.0.4 from the URL : http://www.openqa.org/selenium-ide/
Ø   Open the Mozilla Firefox browser
Ø   On the browser click on File - > Open File.. ->selenium-ide-1.0.4 (open the XPI file)
Ø    Go to tools option in the browser and click on  Selenium IDE and the tool gets invoked.

image005.jpg                                 image007.jpg


Record a Test

Ø   Once the Selenium IDE is invoked the tester can start navigating the AUT.
Ø   The flow is captured by selenium and be viewed under the table / source option.
Ø   The recorded script can be converted to java,. NET, Perl, Python and Ruby.
Ø   Test can be saved as per the tester’s requirements.

image008.jpg

Play back of a test

Ø   The recorded scripts can be played back by clicking on the ‘Play’ button

image013.jpg


Breakpoint

Ø   The tool offers the facility of breakpoint, where the script can be halted anywhere
Ø   After analyzing the script can be resumed
Ø   The speed of the scripts can be controlled by setting speed from fast to slow

image014.jpg
How Selenium Identifies Object
Ø  Actions
Ø  Accessors
Ø  Element Locators
Ø  Variables

Actions
Ø  Where the test actually “does something”.
Ø  Most actions typically take an element locator and possibly a value.
Ø  All actions have an additional “AndWait” sister-action.

Example:

Ø  check - check a checkbox
Ø  click - click a link, button, image, etc
Ø  open - opens a URL in the browser
Ø  select - selects a value from a drop-down
Ø  submit - submits a form
Ø  type - types a value in to a textfield/textarea

              Accessors
Ø Accessors are always “data related”
Ø  Accessors typically take only an element locator.
Ø  Accessors have seven permutations:
§  store (locator, variable*)
§  verify and verifyNot (locator, pattern)
§  assert and assertNot (locator, pattern)
§  waitFor and waitForNot (locator, pattern)

                Example
Ø  alert - the text of the most recent alert box
Ø  bodyText - the contents of the HTML body
Ø  eval - the return value of the JS expression
Ø  table - the contents of a specified row/col
Ø  text - the contents of the specified element
Ø  title - the title of the HTML page

             Element Locators
Ø  id=
Ø  name=
Ø  identifier=
Ø  dom=javascriptExpression
Ø  xpath=xpathExpression
Ø  link=text
Ø  css=cssSelectorSyntax
Ø  If no prefix is specified, the following strategies are used:
·         dom, if the locator starts with “document.”
·         xpath, if the locator starts with “//”
·         identifier, for all other

            Variables and Parameter

Ø Allow for basic logic in your scripts.
Ø  storeXxx comands take variables:
            Example:
Ø  storeValue nameField firstName
Ø  assertTextPresent ${title} ${firstName}

          Addons which helps Us in Identifying Locators:
Ø  Firebug for Mozilla Browser
Ø  IE Developer Tool Bar for IE

     Frequently used selenium commands

S.No
S.No Object/Property Command
S.No Object/Property Command
1
Text Box
getValue(), getText(), isEditable(), isVisible(), type()
2
List Box
getSelectedId(),getSelectedIndex(), ,
getSelectedLabel(),getSelectedValue(),
getSelectOptions(), select()
3
Multi Select / Element
getSelectedIds(),getSelectedIndexes(),
getSelectedLabels(),getSelectedValues(),isSomethin
gSelected()
4
Radio Button
check(), click(), isChecked()
5
Check Box
Check(), click(),isChecked(), uncheck()
6
Button
click()
7
Link
click(), getAllLinks()
8
Text
getText(),getBodyText()
9
Tables and Cells
getTable()

User Extensions


image017.jpg

Sample Extensions:
getVal extension – Helps to read the value from extension file
Flow control extension – Helps to incorporate the looping statements inside the script
UI element – Helps to create the object repository

@Note : Selenium IDE is generally used in Organizations where there is lack of Experienced Testers. For more programming Concepts to be implemented we would go for Selenium RC .

Limitations 0f SeIDE

Ø  Browser
      -Selenium IDE is only available for the Firefox. It cannot be used for different browsers.
Ø  Language
    –Selenium IDE can execute scripts created in Selenese only.
Ø  Complexity
   –It is difficult to use Selenium IDE for checking complex test cases involving dynamic contents, Parameterization, Loops.

So What Next ??
 We can use Selenium Remote Control

Selenium Remote Control

Ø  A server, written in Java and so available on all the platforms.
Ø  Acts as a proxy for web requests from them.
Ø  Client libraries for many popular languages.
Ø  Bundles Selenium Core and automatically loads into the browser

How RC Works
image020.jpg

Install And Start

Ø  Ensure that JDK is present on the machine and is in the class path.
Ø  Downloaded Selenium RC from http://www.openqa.org
Ø  Unzip to any directory on your file system.
Ø  Change directory to the Selenium Server on the command line or terminal.
Ø  Start Selenium Server.

cid:image021.png@01CAA660.3BAEE7B0

Selenium Client Drivers

Ø  Enables communication with Selenium Remote Control Server.
Ø  Functionality of Selenium is exposed via these drivers.
Ø  Available in Ruby, Python, Java, C-Sharp …and so on.
Ø  Give access to the rich features and libraries of the language, including their unit testing framework.
Ø  Makes it possible to develop automated scripts in the same language as product.
Ø  Which one you should use?
      –Whatever make sense in your context. I have been  running Test Scripts using Eclipse Java IDE using JUNIT and TestNG framework.

View of Eclipse: Script written using JUNIT Framework
image022.jpg

View of Selenium RC runner :



Reporting

Report is customizable. A typical TestNG framework report would like :
image031.jpg

Roadmap

Google is investing heavily on Selenium and they have come out with the latest version of Selenium RC 2.0.