Monday, 26 September 2011

Object repository FAQ


Question: Types of OR (Object repository)?
Answer: There are two types of object repository Per action repository and Shared repository
Per action repository
Shared repository
1.Saves in the action folder under test folder while saving a test
1. Saves in a separate folder other then test and we can it as follows .
Dim App
Set App = CreateObject("QuickTest.Application")
blnOR=App.Test.Actions(strActionName).ObjectRepositories.Find(ORPath)
2. We mainly use it for very small test
2.We mainly use it for big test where we have to interact with so many function or actions .
3.Extention is .mtr
3.Extention is .tsr .

Question 2: How to Merge OR.
Answer 2: We can merge OR as follows.
Navigate: Resources > Object repository manager
In object repository manager open Tool: > Object repository merge Tool


It will navigate to following screen.
Browse primary file and secondary file  and click OK

After merging it display a message like below:

We can select option from following as per the requirement:


After taking consideration all the conflict we can save the repository.



Question: How to compare two OR ?
Answer : We can compare OR as follows.
Navigate: Resources > Object repository manager
In object repository manager open Tool: > Object repository comparison Tool

It will navigate to following screen.
Browse primary file and secondary file and click OK

It will display result as follows

All the matched objects will get highlighted

Question: How to associate OR as per the action?
Answers: We can associate OR as per the actions as follows.
Navigate: resources > associate repositories

It will open new windows as 
In this window we can just select the repository and select the actions required in test with that repository.

                                                                                                                     


Monday, 19 September 2011

Type of recording available in QTP



Normal Recording: Normal recording option is available in QTP that captures all the mouse movements and keyboards operations on the basis of mandatory and assistive property of the objects available in QTP .

Low Level Recording : This is the form of recording which QTP does on the basis of mouse movement using coordinate on the screen .It works even though QTP is not able to identify the objects available on the screen .
Example :
Window("Mozilla Firefox").Activate
Window("Mozilla Firefox").WinObject("MozillaWindowClass").Click 607,248
Window("Mozilla Firefox").WinObject("MozillaWindowClass").Click 635,246
Window("Mozilla Firefox").WinObject("MozillaWindowClass_2").DblClick 326,292
Window("Mozilla Firefox").Activate

Helpful : When QTP is not able to identify the objects present on AUT   .
Drawback : It will not work in different resolution .

 Analog recording: Analog recording is done on the basis of mouse movement and generates only one line of code as follows, this one also works even though QTP is not able to idendify the object available on the screen.

Window("Windows Internet Explorer").RunAnalog "Track1"


Helpful : If we have to test a signature in AUT   .
Drawback : It will not work in different resolution .


Note # We can do Analog Recording and Low Level recording only when normal recording is already started.

Thursday, 1 September 2011

Descriptive Programming


Hi All,

  I this post I would like to discuss on descriptive programming one of the most important and complicated looking feature of QTP so I would like answer all the questions which arises when we start any new topic .
  
What is descriptive programming?

    As the name suggest it is some thing that is related to description then question comes into mind that description of what? So the answers is description of objects .As we know that QTP identifies the objects of AUT using the values of the properties available in object repository and in descriptive programming we give those values of objects with the help of descriptive programming so now there is no use to have those objects in OR .
We can provide the description of the objects in set line of codes and then QTP identifies that object in the behalf of the description.

When descriptive programming?

    As I have already told you that on using descriptive we can directly remove the OR stuff so basically we use descriptive programming when .

  •  We don’t want to use object repository at all.   
  •  Size of OR is too huge.   
  •  Objects and their properties are very stable. 


How to use descriptive programming?

  We use descriptive programming using two ways. 

  • String argument to access the objects.   
  •  Create object with the collection of their properties.


Step 1:  First of all we should identify the object of which description we want to create.
Step 2:  Now select that Object using Object Spy for Example if we have spy this edit box it will look like this.



                                              For browser:                              For page:                             


 Step 3: Then we have to identify the properties and its values because now we have to identify the object at run time with the help of giving the name of the object in the code itself.
e.g. for browser if we se title property is having value as “Google – Window Internet “
So reach to that browser we have write as browser(title:= Google – Window Internet) never forget to put “:=” colon then equal to sign .
 In the same manner we have to identify the page property and its value ,be very careful while selecting the property because it has to unique as compare to other object.

The above one was string format now if we talk about the (collection of their properties) we need to define a description class .

Set desc = description.Create
desc("micclass").value = "Browser"
desc("title").value="Google - Windows Internet Explorer*"

Example 1 : = This very common question in interview “Count the Number of links in a given page using DP”



Close 3rd  Open browser
Browser("CreationTime:=2").close
Since CreationTime starts from 0 and you very well manipulate these questions into many more new questions .

Wednesday, 24 August 2011

The key enhancements in QTP 11.0


1) Support for new Operating Systems:
QTP 11.0 has added new support for the following operating systems:
a) Windows 7
b) Windows Vista SP2
c) Windows Server 2008 SP2
d) Windows Server 2008 R2
2) Enhanced Data Management Facility:
QTP is now seamlessly integrated with HP ALM (Application Lifecycle Management) software. Quality Center (HP ALM) test configuration functionality enables us to determine at runtime which data sets to use for our tests.
ALM test configurations enable us to:
a) Unbind our data from our tests
b) Share common data sources across different tests
c) Filter our data to fit our testing needs
d) Increase requirements traceability
e) We store the data for our tests in the Quality Center Test Resources module in the form of data table resource files.
We can then define multiple test configurations for a test in the Test Plan module. When working with data-driven QTP tests in HP ALM, each configuration is a QTP test that is set to run with a selected data resource file and optional data filter settings.
One or more specific configurations of the test can be included in a Test Set to cover different parts of a requirement or to cover multiple requirements.
By using Quality Center test configurations, we can create more generic tests and reuse them by associating a different set of data with each. We can also reuse our data by associating the same data table file with multiple tests.
New QTP Asset Upgrade Tool for HP ALM and Quality Center:
The QTP Asset Upgrade Tool for HP ALM/Quality Center enables us to upgrade, in a batch, all the QTP assets in an HP ALM or Quality Center 10.00 project from QTP 9.5 or earlier to the current format and to convert testing document attachments to the resources and dependencies model.
The QTP Asset Upgrade Tool for HP ALM/Quality Center also enables us to upgrade our tests to use the new test configurations feature. If our tests contain data table parameters that are stored in the Global sheet of a QTP data table, this tool copies those data table parameters to our HP ALM or Quality Center project, enabling us to start working with HP ALM test configurations.
File: In file option we have an extra feature to add ALM with QTP 
In QTP 11 ALM / QC version connection                                     
ALM / QC version control

 
3) New Object Spy Functionality:
The Object Spy has the following new features:
a) Add an object to a repository: We can now add an object to the object repository directly from the Object Spy.
b) Highlight an object in our application: When we select a test object in the Object Spy Object hierarchy tree, we can then select to highlight the object in our application that corresponds to that test object.
c) Copy/paste object properties: We can copy the identification properties and values of a selected test object in the Object Spy and paste the details into any document. The details are formatted in programmatic description syntax. This option is especially useful if we want to compare the properties and values of two objects in our application or when creating programmatic descriptions.
Additionally, the Object Spy has a new, cleaner look and feel:
4) New Smart Regular Expression list:
The Smart Regular Expression list provides syntax hints that make it easier than ever to insert regular expressions into our test steps. It also enables us to access the Regular Expression Evaluator, which lets us test regular expressions to make sure they suit our needs. 





5) New QTP-Service Test integration facility:
Now we can test our GUI and UI-Less Application Functionality in One Test. We can use QTP steps to start testing the GUI elements in our application, then call a Service Test test to validate service communications (standard Web Services, non-SOAP Web Services, such as REST, etc.), and then step back into our QTP GUI testing, all in a single test run.
The results of the QTP and Service Test steps are displayed in a unified report in the new Run Results Viewer.
                                                                                                                       
Service Test Integration Overview :
Service Test enables you to test your GUI-less applications (also known as headless applications). For example, you can use Service Test to test standard Web Services, non-SOAP Web Services, such as REST, and so on.
You can include calls from your QuickTest test to Service Test tests if:
  • Service Test 11.00 is installed on the QuickTest computer, and
  • QuickTest is using an HP Unified Functional Testing (also known as UnifiedFunctionalTesting) license.
When you insert a call to a Service Test test, the call is displayed under the relevant QuickTest action in the Test Flow pane.
If QuickTest is connected to a Quality Center project that contains Service Test tests, you can call a Service Test test that is stored in that Quality Center project. When you run the test, make sure that the QuickTest client on which you run the test has access to an HP Unified Functional Testing license.
You insert and modify calls to Service Test tests using the Call to Service Test Test dialog box. When you insert a call, you specify the parameter values that QuickTest will use when running the test. QuickTest creates an XML file containing these parameter values and stores the file in the relevant action's folder. You can modify the parameter values, if needed, using the Call to Service Test Test dialog box.
Example:
   Suppose you want to insert a step that calls the MyServiceTest test (MyServiceTest.st) in the first action in MyQTTest.
After you insert a call, QuickTest creates C:\Program Files\HP\QuickTest Professional\Tests\MyQTTest\Action1\MyServiceTestParams-1.xml. This XML files contains all of the parameter values that are used when QuickTest runs the MyServiceTest test when the step calling that test is reached during the run session. (If you need to rename the XML file for any reason, make sure that you also modify the name of the XML file in the step that calls it.)
  How QuickTest Runs the Called Service Test Test
When a step containing a call to a Service Test test is reached, QuickTest opens the called Service Test test and runs it. During the run session, the Service Test Monitor window displays a log of the steps that are being performed in the Service Test test. For details on what is contained in these steps, see your HP Service Test documentation.

 

The run session behavior is different depending on whether the QuickTest test is run from QuickTest or from Quality Center.
  • QuickTest. The test runs until the step calling the Service Test test is reached.
If an HP Unified Functional Testing license is currently in use, Service Test opens and runs the Service Test test. When the Service Test test is finished, QuickTest continues running your QuickTest test from the next step.
If QuickTest is not running with this license type, QuickTest fails the test.
  • Quality Center. If an HP Unified Functional Testing license is available, QuickTest opens with that license and runs the test. If this license type is not available, QuickTest does not open and the test does not run.
After the run session, the results display information about the QuickTest test and the called Service Test test. You can view these results in the Run Results Viewer. For details, see QuickTest Tests Containing Calls to Service Test Tests.



6) New Run Results Viewer:
The new Run Results Viewer provides an Executive Summary page with summary data, pie charts and statistics for both the current and previous runs, a quick link to the previous run results, and more.
The Run Results Viewer displays the results of our run session in a set of panes that we can show, hide, move, dock, and otherwise customize to our needs.
We can install the Run Results Viewer as a standalone installation. This enables us to share the results of our tests with business analysts and developers who do not work with QTP. 

It saves the Current and the previous runs for the same location .

Details of result is as follows 

 
7) New facility to hide the Keyword View:
If we prefer working only with the Expert View, we can now use an option in the Options dialog box to hide the Keyword View so that only the Expert View is displayed when we open QTP Professional.
To access : Select Tools > Options > General node.


8) Facility to add Images to Our Run Results:
We can now add a Reporter.ReportEvent statement that includes an image file path. This lets us add an image to the run results wherever one is needed.
9) New Log Tracking Functionality:
QTP's new Log Tracking functionality helps us work with developers to pinpoint the root causes of unexpected behavior in our application.
When we enable log tracking, QTP receives the Java or .NET log framework messages from our application and embeds them in the run results.
We can click a log message in the results to jump to the relevant step in the run results tree, or we can click a step in the run results tree and view the log message that was generated at the time that the selected step ran. We can also specify that a log message of a particular level (or higher) will fail our test.
After we view the results, we can print or export the log tracking details to a file to show to a developer, or we can provide the developer with the standalone Run Results Viewer installation so that the developer can view and analyze the results directly on his or her own desktop.
10) Automatic Parameterization of Steps:
We can instruct QTP to automatically parameterize the steps in our test's actions at the end of a recording session.
This enables us to create actions that can be used for a variety of different purposes or scenarios by referencing different sets of data.
We activate this option by selecting the automatically parameterize steps option in the General tab of the Options dialog box. We can set the option to use Global Data Table Parameters or Test Parameters.
When we stop a recording session while this option is selected, QTP replaces the constant values in the test object operation arguments of our steps with either Data Table parameters or action parameters, based on our selection in the Options dialog box.
QTP performs this automatic parameterization for all relevant steps in any action in our test, in which we recorded one or more steps during that recording session.
If we work with HP ALM, and we select the Global Data Table Parameters option, we can map the generated parameters to the column names of a data resource and then use different configurations in our test sets.
11) New Visual relation identifiers:
We can now use visual relation identifiers to identify application objects based on other objects that are always near them.
This enables us to create a more reliable identification definition for test objects that are otherwise difficult to differentiate, and to ensure that the identification remains reliable even if the user interface design changes.
The Visual Relation Identifier Dialog Box provides the interface and tools to help us create and verify our visual relation identifier definitions.
12) Visual indication of Version Control Status of Tests:
If we are working with version control in HP ALM or Quality Center, QTP provides a visual indication to show us when an asset is checked into or out of a project.
Tests, components, and function libraries that are part of version controlled projects stored in HP ALM or Quality Center display an icon and/or text in the title bar, indicating their version control status.
13) Web 2.0 add-ins support:
QTP 11.0 provides Web Add-in Extensibility-based add-ins for ASP .NET Ajax, GWT, Yahoo UI, and Dojo Web 2.0 toolkits.
We can use these add-ins just as we would any other add-in. We can also use Web Add-in Extensibility or Extensibility Accelerator to customize the provided support to match our needs.
We install these add-ins by running the Web 2.0 Toolkit Support Setup from the Add-in Extensibility and Web 2.0 Toolkits option in the QTP setup window.
The operations supported for each Web 2.0 test object class are a combination of custom operations developed for that test object class and operations directly inherited from the corresponding (base) Web Add-in test object class.
14) New capabilities for working with Web-Based objects:
Following new testing capabilities are now available handling Web-Based objects.
a) Firefox Testing: Us can now record steps on Mozilla Firefox and use the.Object property to access the Firefox DOM.
b) XPath, CSS, Identifiers: Us can add the XPath or CSS identifier properties to instruct QTP to identify a Web object in our application based on its XPath location or CSS definition.
c) Event Identifiers: Us can also now use the attribute/* notation in the test object description to identify a Web-based object based on an event associated with that object. For example, us can add attribute/onClick as a property in a WebButton test object description to identify a button that is associated with the onClick event.
d) Embed or Run JavaScripts in our Web Pages: We can use the new EmbedScript/EmbedScriptFromFile and RunScript/RunScriptFromFile functions to embed JavaScripts in all loaded browser pages and frames or to run JavaScripts in specific pages. Use these scripts to perform operations on, or retrieve data from, the browser pages in our application.
15) New methods for testing Web-based Operations:
The following methods are available to test Web-based applications:
a) AnyWebBasedObject.RightClick / MiddleClick
b) Brower.ClearCache
c) Browser.DeleteCookies
16) New LoadFunctionLibrary statement:
The new LoadFunctionLibrary statement lets us load a function library when a step runs instead of at the beginning of a run session. This means, for example, that us can define conditional steps that use functions from various function libraries, but load only the required function libraries during a run session.
17) Improved checkpoints and output value objects management:
We can now manage checkpoints and output value objects when comparing, merging, and exporting object repositories just like any other test object, including filtering, searching, and conflict resolution.
18) Dual Monitor Support:
QTP recognizes objects across multiple monitors, meaning that our application display no longer needs to be limited to one screen. Alternatively, we can view QTP on one monitor while the steps run on our application on another monitor.
20)
21) Improved Web Add-in Extensibility:
We can now develop browser-independent Web Add-in Extensibility support sets that support testing custom controls on both Internet Explorer and Firefox, and on different versions of these browsers.
We can introduce external JavaScript libraries in our Web Add-in Extensibility support sets, enabling us to call their functions from within the JavaScript functions we develop to support custom controls.
QTP's performance when learning, spying, and running steps on controls supported by Web Add-in Extensibility is improved.
22) Improved Business Process Testing:
QTP 11.0 provides the following enhancements for business process testing when working with HP ALM:
# Improved performance.
# Application areas are now stored in the HP ALM Test Resources module as resources.
This enables us to apply version control to an application area, view at a glance which components are using a specific application area, see which resource files are associated with a particular application area, share our application areas with other projects, and so on.
# Local system monitoring is now supported for component runs.
# All component parameters in HP ALM are now inserted as string value types. From HP ALM, we can use options to encrypt these parameter values or to apply dynamic date values.
23) New QTP-Service Test integration Facility:
The new QTP-Service Test integration enables us to test across the GUI and non-GUI layers of our application.
We can use QTP steps to start testing the GUI elements in our application, then call a Service Test to validate service communications (standard Web Services, non-SOAP Web Services, such as REST, etc.), and then step back into our QTP GUI testing, all in a single test run.
The results of the QTP and Service Test steps are displayed in a unified report in the new Run Results Viewer.
24) New Extensibility Accelerator for Functional Testing:
The new Extensibility Accelerator for Functional Testing is a Visual Studio-like IDE that facilitates the design, development, and deployment of Web Add-in Extensibility support.
It provides a user interface and special tools that help us define new test object classes, map those test object classes to the controls in our application, and teach QTP how to identify the controls, perform operations on the controls and retrieve their properties.
We install the Extensibility Accelerator from the Add-in Extensibility and Web 2.0 Toolkits option in the QTP Professional setup window.
Reference: Notes compiled from HP User Guide on Functional Testing Software v11.x QTP 11.0
 







Monday, 8 August 2011

Count Number Of words in String/Document

str = "my name is pankaj"
words= Split(str," ")
MsgBoxUBound(words)+1
'In case If you have to count the number of word in Notepad then you can use the following approch .

Set np = CreateObject("scripting.filesystemobject")
Set onp = np.OpenTextFile("C:\Documents and Settings\sharmapa\Desktop\Blog.txt",1)
str = onp.ReadAll
words= Split(str," ")
MsgBoxUBound(words)+1

Saturday, 6 August 2011

dot net factory to get system information



Using class
Dotnetfactory.CreateInstance("Microsoft.VisualBasic.Devices.Computer","Microsoft.VisualBasic")



Set Obj = otnetfactory.CreateInstance("Microsoft.VisualBasic.Devices.Computer","Microsoft.VisualBasic")
Set compinfo = Obj.Info
print "AvailablePhysicalMemory -" & compinfo.AvailablePhysicalMemory
print "Availablevirtualmemory-" & compinfo.Availablevirtualmemory
print "OSFullname  -"& compinfo.OSFullname
print "OSPlatform- "& compinfo.OSPlatform
print "OSVersion -" & compinfo.OSVersion
print "TotalPhysicalmemory-" & compinfo.TotalPhysicalmemory
print "TotalVirtualmemory" & compinfo.TotalVirtualmemory

Set compinfo = nothing


(Dot net factory) Now put ProgressBar into windows form using the following class


Set MyProgressBar = DotNetFactory.CreateInstance("System.Windows.Forms.ProgressBar", "System.Windows.Forms")

Now we are applying progress bar in the windows form

Set MyForm = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
Set MyProgressBar = DotNetFactory.CreateInstance("System.Windows.Forms.ProgressBar", "System.Windows.Forms")
Set Pos = DotNetFactory.CreateInstance("System.Drawing.Point", "System.Drawing")
Pos.X = 100
Pos.Y = 100
With MyProgressBar
.Maximum = 100
.Minimum = 0
.Step = 20
.Location = Pos
End with
MyForm.Controls.Add MyProgressBar
MyForm.Show
For i = 0 to 5
MyProgressBar.PerformStep()
Next
MyForm.Close


(Dot net factory) Now create radio button in windows form


Set MyRadioButton1 = DotNetFactory.CreateInstance("System.Windows.Forms.RadioButton", "System.Windows.Forms")

Check the following example :

Set MyForm = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
Set MyRadioButton1 = DotNetFactory.CreateInstance("System.Windows.Forms.RadioButton", "System.Windows.Forms")
Set MyRadioButton2 = DotNetFactory.CreateInstance("System.Windows.Forms.RadioButton", "System.Windows.Forms")
Set MyButton = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")
Set Pos = DotNetFactory.CreateInstance("System.Drawing.Point","System.Drawing",x,y)
With Pos
.X = 90
.Y = 100
End With
With MyRadioButton1
.Location = Pos
.Text = "Option 1"
.Name = "optRadioButton1"
End With
With Pos
.X = 90
.Y = 130
End With
With MyRadioButton2
.Location = Pos
.Text = "Option 2"
.Name = "optRadioButton1"
End With
With Pos
.X = 90
.Y = 160
End With
With MyButton
.Location = Pos
.Text = "Close"
End With
With MyForm
.Controls.Add MyRadioButton1
.Controls.Add MyRadioButton2
.Controls.Add MyButton
.CancelButton = MyButton
.Text = "My Custom User Form"
.ShowDialog
End With
If MyRadioButton1.Checked Then
msgbox "You have selected - Option 1"
elseif MyRadioButton2.Checked then
msgbox "You have selected - Option 2"
else
msgbox "No Options Selected"
End If
Set MyRadioButton1 = Nothing
Set MyRadioButton2 = Nothing
Set Button = Nothing
Set Pos = Nothing
Set MyForm = Nothing



(Dot net factory) Now check checkbox with a button and passing the controls accordingly


Set Form = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
Set Checkbox = DotNetFactory.CreateInstance("System.Windows.Forms.CheckBox", "System.Windows.Forms")
Set Pos = DotNetFactory.CreateInstance("System.Drawing.Point","System.Drawing",x,y)
Set Button = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")
With Pos
.X = 90
.Y = 100
End With
With CheckBox
.Location = Pos
.Text = "My Check Box"
.Name = "chkCheckBox"
End With
With Pos
.X = 100
.Y = 130
End With
With Button
.Location = Pos
.Text = "Close"
End With
With Form
.Controls.Add CheckBox
.Controls.Add Button
.CancelButton = Button
.Text = "My Custom User Form"
.ShowDialog
End With
If CheckBox.Checked then
         msgbox "Check box Checked"
         else
        msgbox "Check box unchecked"
end if
Set CheckBox = Nothing
Set Button = Nothing
Set Pos = Nothing
Set Form = Nothing


If check box checked then

If checked box not checked