Blog to understand automation concepts in QTP, Selenium Webdriver and Manual Testing concepts

Automation Object Model in QTP : Questions and Answers

In this article, we will try to understand Automation Object Model in QTP through subjective and multiple choice questions:

Question 1: What is UFT AOM?


Answer: AOM stands for Automation Object Model.The UFT AOM is a set of objects, methods, and properties that enable you to control essentially all test settings ad test options. Using the objects, methods, and properties exposed by the UFT automation object model, along with loops and conditional statements, we can perform following tasks using Automation object model:
1.   Execution of Test Scripts from VB Script. This helps in execution of tests from QTP and scheduling tests to run on remote machine. Test can be run in host machine/remote machine but QTP needs to be installed in host/remote machine in which test script needs to be executed.
2.  We can change configurations (Test Settings and options) at runtime of QTP tests.
3.  We can save test or component using AOM.
4.  Using Initialization script that launch UFT automatically can enable same settings/options executing from multiple machines.

Question 2: We can create an object of Quick Test in VBScript using ......


a.      Set qtApp = CreateObject("QuickTest.Application", "MyServer")
b.      Set qtApp = CreateObject("QuickTest.Application")
c.       Set qtApp As CreateObject("QuickTest.Application")
d.      Set qtApp as CreateObject(“Scripting.QuickTest”)

Answer: We can create an object of QuickTest in VBScript using a) or b). We need to provide server details as shown in option a), in case we need to run test on a remote machine. In case we have to run test in the same machine, we can use option b), i.e without Server Parameter.

Question 3: How can we associate a library at runtime with QTP test using AOM?


Answer: We can add a library using AOM as follows:

Create an object of QTP object.
Set qtApp = CreateObject(“Quicktest.Application”);

Multiple libraries can be associated with test as follows:
qtApp.Test.Settings.Resources.Libraries.Add "C:\Common_Func.vbs"
qtApp.Test.Settings.Resources.Libraries.Add "C:\Business_Func.vbs"
files = "C:\Common_Func.vbs| C:\Business_Func.vbs"
qtApp.Test.Settings.Resources.Libraries.Add(files)
In addition to AOM, we can associate libraries using function LoadFunctionLibrary FileName or ExecuteFile FileName

Question 4: Can we generate script automatically for all test settings and options: Yes/No


Answer: We can generate AOM scripts for all test settings, and test options in QTP.
a.      Script for all the test settings can be generated from File>Settings>Properties
b.      Script for all the test option can be generated from Tools>Options>GUI Testing>General

Question 5: How can we associate repositories with a test in QTP using AOM?


Answer: An object Repository is associated with action in the test and not the test as whole. We can associate object repository with an action as shown in the example below:

Set Qtpapp = createObject(“Quicktest.Application”)
Qtpapp.Open “C:\SampleTest1”,False,False
Set qtrep = Qtpapp. qtApp.Open "C:\Tests\Test1", False, False ' Opens a test in qtp
Set qtRepositories = qtApp. Test.Actions(“Action1”).ObjectRepositories  ‘Creates an object of repository collection i.e all repositories associated with a test action
If qtRepositories.Find(“C:\ORTest.tsr”) = -1 Then ‘If OR is already associated with a test, do nothing else add the required shared object repository.
    qtRepositories.Add “C:\ORTest.tsr”, 1
End If

Question 6: Can we stop a test execution through AOM?


Answer: Yes, we can stop a test from AOM, but the question arises, why do stop test from AOM when we can stop a test using exitTest statement. Many a times,exit statement does not work in QTP 11 when the exit statement was called from inside functions called from function in vbs library. In case exitTest statement does not work we can exit a test using below code:

Set qtAppObj = CreateObject("quicktest.application")
qtAppObj.Test.Stop

Question 7: Which of the following method of recovery object is used to activate recovery scenario through AOM?

a.      Activate
b.      Add
c.       Enabled
d.      Focus
Answer: we can enable a recovery scenario using enabled method of recovery object.

Question 8: How can we connect to ALM using VBScript?


Answer: Using the below code, we can connect to ALM through VBScript using QuickTest Application object as shown below:
Set qtApp = CreateObject ("QuickTest.Application")
If  qtApp.launched <> True then
     qtApp.Launch
End If
qtApp.Visible = "true"
If Not qtApp.TDConnection.IsConnected Then
      qtApp.TDConnection.Connect QCurl, DomainName, ProjectName, UserName, Password, False
End If


Understanding Menu options in UFT 11.5: Questions and Answers

This is first of the topics in understanding about menu options changes in UFT 11.5 with subjective questions and multiple choice questions. We will discuss various questions based on menu options in UFT 11.5.

Question 1: What are the various menus in UFT 11.5 GUI Test?


Answer: The various menus with important functions in UFT 11.5 are as follows:
· File Menu: The file menu provides commands to:
o   Create New Business Component, Function Library, Solution, test, and Application Area.
o   Open existing Business Component, Function Library, Solution, test, and Application Area.
o   Add existing Business Component, test, and Application Area.
o   Save, Close, and view recent tests and other assets.

·Edit Menu: Provides option to edit content of test including cut, copy, delete, undo and redo the changes.
o   Provides option to format the test using comments, uncomment, using with statements
o   Inserting code snippets

·View Menu: Provides various options to view test information :
o   Viewing toolbox, solutions explorer, properties, test flow, and bookmarks
o   Viewing Data pane, debug information in watch, variable, command window
o   Move from keyword view to editor view  and vice versa

·Search: To search content including text and bookmarks

·Design: Design provides option to design the test with actions, checkpoint , step generator ,and function definition generator:
o   Inserting call to new action, call to existing action, call to copy of action, and call to existing API Test.
o   Enhancing test/action with function definition generator, checkpoints, output value and transaction steps.
o   Validating syntax in the code

Record: Provide option for various recording modes, web event recording configuration settings, and record and run setting

Run: provides various option to run a test with run test, run now, Maintenance run mode, update run mode
o   Runs a test from step, step into, step over, debug from step, run to step.
o   Inserting a variable, object to watch, inserting and removing breakpoints

Resources: provides option to view object repository, object repository manager, Associate repository with an action, mapping repository parameters and creating recovery scenarios.

ALM: Provides options to create connections with ALM/QC and versioning feature of resources From ALM

Tools: Provides various tools and options to work with UFT11.5.
o   Provides tools including object spy, .Net Windows Forms spy, Object Identification, regular expression evaluator, data driver, change active screen, extensibility accelerator and virtual objects.
o   Import WSDL, Import .NET Assembly, rest services
o   Defines tools options for GUI Testing, API Testing, coding, text editor and general options.

Windows: Provide option to move from one window to another.

Help: Provides link to various help, UFT support  and installing license for UFT 11.5

Question 2:  What will happen, if I press Ctrl +Q in a UFT function?

a.       Recovery Scenario Page will open
b.      ALM Connection will open
c.       Object repository
d.      Comment a statement

Answer: Ctrl + Q will open ALM connection window, where we can provide details to connect to ALM Server, project details, and password/username details. To open Object Repository, Press Ctrl + R. To comment a statement, Press Ctrl+M.

Question 3: In which menu, Is regular expression evaluator?

a.     Tools
b.      Edit
c.      View
d.      Resources

Answer: The correct Answer is a) tools

Question 4: Shortcut key to view data table is:

a.       Ctrl+Alt+X
b.      Ctrl+Alt+P
c.       Ctrl+Alt+D
d.      Ctrl+Alt+E

Answer: Shortcut key to view data is Ctrl+Alt+D, Ctrl+Alt+X is shortcut for Toolbox, Ctrl+alt+P for properties, Ctrl+Alt+E for errors and Ctrl+Alt+L for Solution explorer

Question 5: What is the shortcut Key to insert a standard checkpoint?

a.       F9
b.      F10
c.       F11
d.      F12

Answer: F12 is shortcut key for standard Checkpoint, Other Shortcut keys are as follows. F9- Insert/Remove Checkpoints, F10 - Step Over, F11 - Step into, F7 - Step generator.

Some other Useful Shortcut keys are: F6 - Record, F4 - Stop, F5 - Run, Ctrl+F5 - Run from step.

Seven Principles of Software testing

Software Testing focuses on ensuring the quality of the software. Software not tested properly can cause many problems including financial losses, reputation loss and at times injury or even death. How much testing is required depends on the risks associated with the software as well as time constraints. There are few principles of testing that can help to better understand the process of testing and define testing process

The principles of testing are as follows:


1.  Testing shows presence of defect  

Testing helps in uncovering defects although we can never be sure that that there are no defects in the software even after testing. So the focus of testing is to find as many defects in the system.

2.  Exhaustive Testing is not feasible


 Going by the first principle, tester can never be sure that there are no defects in the system, One of the reason for first principle is exhaustive testing is impossible. We can test all the scenarios related to software but the time and resource cost for testing exhaustively will be so huge, it will not bring any value and will not be able to deliver software. Due to this proper risk analysis and priorities of scenarios should be taken care of in testing for balanced and timely testing completion.  Test cases should be prepared based on the functional specification, as test cases for high priority scenario should be executed first.

3.  Testing should start as early as possible


 Catching defects early in the Software development life cycle reduces the cost of fixing of defect. For e.g. Testing should start as early as possible, Reviews should take place to identify gaps in requirements understanding, and identify code issues early.  Also test designing should start as soon as possible.

4.  Most of the Defects are confined to small module

This has been noticed that most of the defects are confined to small module; the reason of defects can be understanding gaps in the particular set of modules and the technical skill of the resources.

5.  Pesticide Paradox

 Executing the same test cases again and again eventually results in no defects being identified by test cases. Due to this reason test cases should be reviewed from time to time, with new test cases added and redundant test cases removed from the regression pack to keep the test suite fresh, up to date and effective. Test cases must include both manual and automated test cases for higher coverage of test scenarios.

6.  Testing requirement varies from software to software 

Testing is done differently for different software. A social networking site will have different requirement of content and performance testing compared to banking software that will require functionality and security as main factors compared to the social networking site. The testing requirements should be well defined in the scope of testing.

7.  The software developed should be usable by user

and should meet user’s need and expectation. It does not matter if there were no defects in testing the software if it does not meet the need of end users.Software