Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Thursday 20 December 2018

Navigating to one t-code from another using UFT

SAPGuiSession("Session").Reset  // This code will take you to home page, doesnt matter where you are.


SAPGuiSession("Session").Reset "VA03"    //This code will take you to VA03 t-page from anywhere.



Wednesday 19 December 2018

Recording Modes in UFT

But before that let’s discuss the need of different types of recording modes. There are cases when we need to record continues mouse movements, or there are cases when we need to store object on the bases of its co-ordinates, sometimes we need to record images of object, So recording modes are divided into following 4 parts on the bases of requirement:
1. Normal/Default Recording Mode,
2. Low level Recording Mode,
3. Analog Recording Mode and
4. Insight Recording Mode
I would like to tell you one thing here i.e. the sequence in which I have defined the recording modes above is the same sequence of priority, I mean if we are going for recording then first we will try to record in Normal Mode then Low level then Analog and at the end Insight Recording Mode.
Let’s start with detailed explanation of each and every recording mode:
1. Normal/Default Recording Mode:
As the name says this is the default recording mode of UFT/QTP. Whenever user starts recording by default recording done in this recording mode.
This recording mode is used to recognize standard objects of the AUT and save the object properties into the Object Repository (OR), it is also uses to record mouse movements & keyboard inputs.
Let’s have a look at this recording mode:
Start recording by using shown option in the screenshot below:
1_StartRecording
Once the recording has been started one can see in the below screenshot Normal/Default recording mode is selected by default:
2_WhileRecording
And this is how scripts recorded in normal mode are looks like:
4_NormalRecordingMode
2. Low level Recording Mode:
Low level recording is used to record mouse clicks, drag & drop, and type operation on an object. But the recording is done on the bases of co-ordinates not its properties and i.e. why this recording mode is known as Low Level Recording mode, because in this mode QTP/UFT records the co-ordinate location of the object on which action has been performed.
This is how UFT will look like while low level recording mode:
5_LawLevelRecording
6_LawLevelRecording
Following is the code of Low level recording mode:
7_LowLevelRecordingMode
You can see in the above code, mouse clicks has been recorded as coordinates.
3. Analog Recording Mode:
Whenever we need to record continues mouse movements, we can go with Analog Recording mode. The main funda behind this recording mode is it records your continues mouse movements in the form of a track and save this track file on your computer.
Try following steps to record script in Analog Recording mode:
We need to find out the scenario of continues mouse movement, There is a desktop based Flight reservation application provided by HP for practice purpose. Please find below the path from where you can open that application:
8_SampleAppPath
You can see in the screenshot there are 2 versions of this application first is for GUI based applications and second is for API, as UFT supports both the types of testing. Please launch “Flight GUI” and login into this app using any username (ex. admin) and mercury as password, and perform the following steps:
  1. Place one order
  2. Open that order
  3. Open Order
  4. Try to fax order
You will see following window:
24_ChangeRecordingModeToAnalog
Here you need to do digital signature for faxing any order, and to do that you have to perform continues mouse movements, Continues mouse movements can’t be recorded using Normal or Low level recording mode, to do so you have to take help of Analog recording mode.
Start analog recording by changing the mode as shown in the screenshot above, once the mode has been changed you will find following window:
25_AnalogRecordingOptionOne
You can see in the window there are 2 options:
1st: “Record relative to the screen” says start recording relative to whole desktop screen that means whatever you are going to perform the task it will record.
2nd: “Record relative to the following window” says start recording on a specific window, once you will select the second option window will look like this:
26_AnalogRecordingOption2
You can see there is one hand icon just click on it and then select the specific window on which you want to perform recording, After selecting the window the name of the window will be auto populated in text box as shown above.
Now do your signature in the specific block of the window as shown in the following screenshot:
27_AnalogRecordingScenario
After completing the signature stop recording, and see the UFT script editor. You will find a code like following:
AnalogRecordingMode
Let’s discuss what this code is saying; this line of code is navigating to specific window on which you want to perform analog recording and calling the recorded script using RunAnalog method.

4.Insight Recording Mode:
There are cases when UFT is not able to recognize objects using their defined properties; the reason could be like developer has not assigned properties to object, or the properties assigned to object are not enough that UFT can recognize that object. In this situation we can take help of Insight Recording mode, which records object screenshots and perform actions on that.
Please follow the steps given in the screenshot below to start recording in Insight mode:
30_InsightRecordingMode
As shown in the above screenshot please change the recording mode to Insight.
Now perform all the action normally on the application and then stop recording, please find below the code generated by UFT under Insight recording mode:
31_ScriptForInsightRecordingMode
You can see in the screenshot there is an Insight Object at the place of normal object and under that we are passing screenshot of the object on which we have to perform the action.
32_InsightObjectsInOR
In the above screenshot we have shown the OR for Insight Objects, you can notice in the screenshot that UFT has stored the screenshot of the object at the place of its properties.

Friday 23 November 2018

Difference between Child object, ChildItem and GetCellData

ChildObjects method is to access total child objects from an object using description object. In other words, it returns the collection of child objects contained within the object.

Syntax:- object.ChildObjects ([Description])

eg: for the count of No of links present in a page we can use Child objects method

set odesc = Description.Create()
odesc("Class Name").Value = "oLinks"
set oLinks=Browser("title:=.*").Page("title:=.*").ChildObjects("odesc")
msgbox oLinks.count
  
ChildItem method is to access child objects from a web table cell in web table object without using description object. In other words, it returns a test object from the cell by type and index.

Syntax:-object.ChildItem (Row, Column, MicClass, Index)

EG:

set a = Browser("A").Page("B").WebTable("C").WebTable("Item").ChildItem(2,2,"WebElement",0)
b = a.GetROProperty("value")
MsgBox b

Getcelldata method is to retrieve data from a web table cell in web table object.

Syntax:-object.GetCellData (Row, Column)

EG:

Dim i,j
For i=1 to Row count
  For j=1 to column count

     msgbox browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebTable("Yahoo! ID:").GetCellData (i,j)

  Next
Next

Friday 5 October 2018

What is Worksoft Certify

Worksoft Certify is the industry leading test automation solution for enterprise applications including SAP, Workday, Salesforce.com, Oracle, and Web Apps. Built to test complex business processes that span multiple applications, Certify ensures that your software and business work exactly as planned. It enables business users and QA teams to run automated exploratory, functional, regression and integration tests across hosted and on-premise applications.

Worksoft Certify

Friday 6 July 2018

UFT/QTP DataTable

A DataTable provides a way to create data driven test cases. It's same as Excel sheets and can be used to run an Action Multiple times.

There are two types of DataTable in QTP/UFT:

1. Design-Time DataTable:-

As the name suggest the data table during the script design time is known as design time data table.
Design time datatable are having two types of sheet:-

A)Local Data Table:- Each action has its own private data table also known as local data table which is can also be accessed across actions.The name local data table is somewhat misleading because it's in fact possible to access any action's local data table from any other action.

 B) Global Data Table:- Each test has one global data sheet that is accessible across actions.

Important Point About DataTable:

1. A DataTable is stored as "Default.xls" file in the Test Folder.
2. The same DataTable cannot have duplicate parameter names but we can use same name parameters in different sheets(Global mad Local DataTable)

Difference between Local and Global DataTable:

Global Data Table parameters take data from the Global sheet in the Data Table. The Global sheet contains the data that replaces global parameters in each iteration of the test. By default, the test runs one iteration for each row in the Global sheet of the Data Table.

Local Data Table parameters take data from the action's sheet in the Data Table. The data in the action's sheet replaces the action's Data Table parameters in each iteration of the action. By default, actions run only one iteration.

2. Run-Time Data Table:-  

The run-time datatable contain a copy of the design time data table when a script is executed. It may contain values that are changed during script execution and are presented in the test result summary. The changes made to the data table during the run-time are not saved to design time data 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.


When to use the Global or a Local DataTable:

Global Sheet is used for Global use, that means what you entered in global sheet that should be used in any action in the Test for example: test1 having 4action. at that time you want to parameterize the some object in all actions with same Test Data. at this times used global sheet.

Action Sheet is used for local use, that means if you want to parameterize the actions individually with independent test data in test, at that time we are use Action Sheet.

DataTable Object Model:-

QTP/UFT provides an object model to access various properties and method in a datatable.
there are three types of obejcts:
DataTable, DTSheet, DTParameter.

1. DataTabel:- gives detailed information about the datatable methods and properties.

Data Table Object Methods:
Method NameDescriptionSyntax
AddSheetAdds the specified sheet to the run-time data tableDataTable.AddSheet(SheetName)
DeleteSheetDeletes the specified sheet from the run-time data tableDataTable.DeleteSheet SheetID
ExportExports the Datatable to a new file in the specified locationDataTable.Export(FileName)
ExportSheetExports a Specific Sheet of the Datatable in run-timeDataTable.ExportSheet(FileName,SheetName)
GetCurrentRowReturns the active row of the run-time data table of global sheetDataTable.GetCurrentRow
GetParameterCountReturns the number of columns in the run-time data Table of Global SheetDataTable.GetParameterCount
GetRowCountReturns the number of rows in the run-time data table of Global SheetDataTable.GetRowCount
GetSheetReturns the specified sheet from the run-time data table.DataTable.GetSheet(SheetID)
GetSheetCountReturns the total number of sheets in the run-time data table.DataTable.GetSheetCount
ImportImports a specific external Excel file to the run-time data table.DataTable.Import(FileName)
ImportSheetImports the specified sheet of the specific excel file to the destination sheet.DataTable.ImportSheet(FileName, SheetSource, SheetDest)
SetCurrentRowSets the Focus of the Current row to the Specified Row NumberDataTable.SetCurrentRow(RowNumber)
SetNextRowSets the focus of the next row in the run-time data tableDataTable.SetNextRow
SetPreviousRowSets the focus of the previous row in the run-time data TableDataTable.SetPrevRow
Data Table Object Properties:-
Property NameDescriptionSyntax
GlobalSheetReturns the first sheet of the run-time data table.DataTable.GlobalSheet
LocalSheetReturns the Active local sheet of the run-time data table.DataTable.LocalSheet
RawValueRetrieves the raw value of the cellDataTable.RawValue ParameterID, [SheetID]
ValueRetrieves the value of the cell in the specified parameter.DataTable.Value(ParameterID, [SheetID])

2. DTSheet:- gives detailed information about the DTSheet methods and properties.

DTSheet Methods:-

Method NameDescriptionSyntax
AddParameterAdds the specified column to the sheet in the run-time data table.DTSheet.AddParameter(ParameterName, Value)
DeleteParameterDeletes the specified parameter from the run-time data table.DTSheet.DeleteParameter(ParameterID)
GetCurrentRowReturns the row number of the active row in the run-time Data Table.DTSheet.GetCurrentRow
GetParameterReturns the specified parameter from the run-time Data Table.DTSheet.GetParameter(ParameterID)
GetParameterCountReturns the total number of Columns in the run-time Data Table.DTSheet.GetParameterCount
GetRowCountReturns the total number of rows in the run-time Data Table.DTSheet.GetRowCount
SetCurrentRowSets the Focus on the specified Row of the Data TableDTSheet.SetCurrentRow(RowNumber)
SetNextRowShifts the Focus to the next Row of the Data Table.DTSheet.SetNextRow
SetPrevRowShifts the Focus to the Previous Row of the Data Table.DTSheet.SetPrevRow
3. DTParameter:-gives detailed information about the DTParameter methods and properties.

DTParameter Object Properties:-

Method NameDescriptionSyntax
NameReturns the name of the parameter in the run-time data table.DTParameter.Name
RawValueReturns the raw value of the cell in the current row of the run-time data table.DTParameter.RawValue
ValueRetrieves or sets the value of the cell in the Active row of the parameter in the run-time data table.DTParameter.Value
ValueByRowRetrieves the value of the cell in the specified row of the parameter in the run-time data table.DTParameter.ValueByRow(RowNum)

How To Import and Export Excel Sheet Into DataTable:-

1. DataTable.Import(FileName):-
DataTable.Import("C:\Users\VMalav\Documents\Project_Work\HP Project\Automation Work\HP TestAutomation\Data Files\SupportHome_Page.xls")

2. DataTable.ImportSheet(FileName, vSrcSheet, vDstSheet):-

vFileName ="C:\Users\VMalav\Documents\Project_Work\HP Project\Automation Work\HP TestAutomation\Data Files\SupportHome_Page.xls"
ImportSheet in LocalSheet :
DataTable.ImportSheet(vFileName, 1, 1) -> Import 1st sheet of excel into global sheet

DataTable.ImportSheet(vFileName, 1, 2) -> Import 1st sheet of excel into Local or Action sheet

3. DataTable.Export(FileName):

DataTable.Export("C:\Run-Time DataTable.xls") -> Export run-time datatable in "Run-Time DataTable.xls" 

4. DataTable.ExportSheet(FileName,  vSrcSheet, [Optional] vDstSheet):-

DataTable.ExportSheet("C:\Run-Time DataTable.xls", 1, 1) -> Export runtime datatable to excel sheet.


How To Read Data from DataTable:-

1. Reading Data From Global DataTable:-

Msgbox DataTable.Value("A", dtGlobalSheet)
or
Msgbox DataTable.Value("A", 1)
or
Msgbox DataTable.Value("A", Global)
or
Msgbox Datatable ("A" , 1 )
or
Msgbox Datatable("A", dtGlobalSheet)
or
Msgbox Datatable("A", Global)

2. Reading Data From Local DataTable:-

Msgbox DataTable.Value("A", dtLocalSheet)
or
Msgbox DataTable.Value("A", 2)
or
Msgbox DataTable.Value("A", "Action1")
or
Msgbox Datatable ("A" , 2 )
or
Msgbox Datatable ("A" , "Action1")
or
Msgbox Datatable ("A", dtLocalSheet)

3. Reading a value from another action's datatable:-

Msgbox DataTable.GetSheet("Action2").GetParameter("A").Value
Msgbox DataTable.GetSheet("Global").GetParameter("A").Value
Msgbox DataTable.GetSheet(1).GetParameter("A").Value

4. Reading a value from external action's datatable:-

Msgbox DataTable.GetSheet("sac [rd]").GetParameter("A").Value

rd - > Test name
sac-> Action name

5. Retrieving a value of the cell from the specified row of the datatable:-

Msgbox (DataTable.GetSheet(2).GetParameter("A").ValueByRow(3))
or
Msgbox (DataTable.GetSheet("Action1").GetParameter("A").ValueByRow(3))
or
Msgbox (DataTable.GetSheet("Global").GetParameter("A").ValueByRow(3))

6. Retrieving a value of the cell in the specified row of the Global or Local datatable:-

Msgbox(DataTable.GlobalSheet.GetParameter("A").ValueByRow(3))
Or
Msgbox(DataTable.LocalSheet.GetParameter("A").ValueByRow(3))



How To Write Data in DataTable:-

1. Adding a value to Global Sheet:-

DataTable.GlobalSheet.AddParameter "A", 1
or
DataTable.GetSheet(1).AddParameter "A", 1
or
DataTable.GetSheet("Global").AddParameter "A", 1
or
DataTable.Value("A", 1)=99
or
DataTable.Value("A", Global)=99
or
DataTable("A", 1)=77
or
DataTable("A", Global)=77


2. Adding a value to Local Sheet:-

DataTable.LocalSheet.AddParameter "A", 1
or
DataTable.GetSheet(2).AddParameter "A", 1
or
DataTable.GetSheet("Action1").AddParameter "A", 1
or
DataTable.Value("A", 2)=99
or
DataTable.Value("A", "Action1")=99
or
DataTable("A", 2)=63
or
DataTable("A", "Action1")=63

Below statement always writes into the Global Sheet:-

DataTable("A")=100

Questions & Answers:-

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

Q.What are Differences between Design time Data Table and Run-time Data Table?
Ans:
Design Time Data Table:
It  is  viewed  in  the  QTP  Main Test
It  is  created  prior  to  the  test execution
It  represents  data  from  external Sources

Run-Time Data Table:
It is viewed in the QTP Test Result Window
It is created in Test Results after test execution.
It represents a live version of design Time Data table.

Q.Inserting a Call to Action is not importing all columns in Datatable of globalsheet. Why? 
Ans: Inserting a call to action will only Import the columns of the Action called

Example

Consider the following DataTable −
Get RowCount and Column Count
'Accessing Datatable to get Row Count and Column Count
rowcount = DataTable.GetSheet("Global").GetRowCount
msgbox rowcount      ' Displays 4
  
colcount = DataTable.GetSheet("Global").GetParameterCount
msgbox colcount   ' Displays 3
  
DataTable.SetCurrentRow(2) 
val_rate = DataTable.Value("Rate","Global")
print val_rate   ' Displays 7%
  
val_ppl = DataTable.Value("Principal","Global")
print val_ppl  ' Displays 2556
  
val_Time = DataTable.Value("Time","Global")
print val_Time  ' Displays 5

Tuesday 26 June 2018

CreateObject in QTP/vbScript

CreateObject is function which creates a reference to the specified object. You can then use the reference object to access the methods/properties of the specified object.

As createobject returns a reference to object, you must use Set to assingn it to a variable.

Set objExcel=CreateObject(“Excel.Application”)
'Adding a workbook
Set objWorkBooj= objExcel.Workbooks.Add
'Activating the sheet
Set objSheet=objWorkBook.Worksheets("Sheet1")
'Writing values to excel
objExcel.Cells(row,column)=<”Your value>


Below is the list of most commonly used objects. I hope you find it useful.


S.No
Object
Description
1
Set ObjectName= CreateObject("Wscript.shell")
Provides access to the native Windows shell. Provides functions to read system information and environment variables, to work with the registry and to manage shortcuts.
2
Set ObjectName = CreateObject("WScript.Network")
Provides access to the shared resources on the network to which the computer is connected.
3
Set ObjectName = Createobject("Excel.Application")
Perform operations on MS Excel.
4
Set ObjectName = CreateObject("Word.Application")
Perform operations on MS Word.
5
Set ObjectName = CreateObject("Outlook.Application")
Perform operations on MS Outlook.
6
Set ObjectName = CreateObject("InternetExplorer.Application")
Perform operations on Internet Explorer.
7
Set ObjectName = Createobject("QuickTest.Application")
Perform operations on Quick Test Professional (QTP).
8
Set ObjectName = CreateObject("QuickTest.UpdateRunOptions")
A collection of properties that indicate preferences for the Update Run in QTP.
9
Set ObjectName = CreateObject("QuickTest.RunResultsOptions")
A collection of properties that indicate preferences for the run results in QTP.
10
Set ObjectName = CreateObject("Scripting.FileSystemObject")
To work with the Windows file system structure: files, folders, drives.
11
Set ObjectName = CreateObject("Mercury.DeviceReplay")
Perform mouse or key operations exactly as they occur on the mouse or keyboard drivers.
12
Set ObjectName = CreateObject("Mercury.ObjectRepositoryUtil")
Perform an operation on QTP Object Repository.
13
Set ObjectName=CreateObjcet("Scripting.Dictionary")
Creates a dictionary object
14
Set ObjectName=CreateObject("vbScript.RegExp")
Creates a regular expression object
15
Set ObjectName = CreateObject("Mercury.FileCompare")
To compare two files.
14
Set ObjectName = CreateObject("Mercury.Clipboard")
Perform clipboard functionality.
15
Set ObjectName = CreateObject("Msxml2.DOMDocument")
Creates a DOMDocument object to perform operations related to XML document.
16
Set ObjectName = DotNetFactory.CreateInstance (TypeName [,Assembly] [,args])
Returns a COM interface for a .NET object.
17
Set ObjectName = Createobject("shell.application")
To instantiate the Shell object, to program the Shell which can be used to access the file system, to launch programs, and to change system settings.
18
Set ObjectName= Createobject("TDApiOle80.TDConnection.1")
An object that enables to manage the Quality Center connection and retrieve the TDOTA object, which provides full interaction with Quality Center.
19
Set ObjectName = CreateObject("Microsoft.XMLDOM")
To access and manipulate XML documents via the XML DOM implementation, as exposed by the Microsoft XML Parser.
20
Set ObjectName = XMLUtil.CreateXML()
Creates and returns an object of type XMLData. If a root name is specified, a new document is created containing the specified root tag.
21
Set ObjectName = CreateObject( "AcroExch.App")
Acrobat OLE Automation Objects.
Set ObjectName = CreateObject( "AcroExch.AVDoc")
Set ObjectName = CreateObject( "AcroExch.PDDoc")
Set ObjectName = CreateObject( "AcroExch.HiliteList")
Set ObjectName = CreateObject( "AcroExch.PDBookmark")
Set ObjectName = CreateObject( "AcroExch.Rect")
22
Set ObjectName = CreateObject("ADODB.Connection")
Creates an instance of the ADO connection to connect to database.
23
Set ObjectName = CreateObject("ADODB.Recordset")
Creates an instance of the recordset object. To be able to read database data, the data must first be loaded into a recordset.
24
Set ObjectName =CreateObject("msscriptcontrol.scriptcontrol")
Perform operations to MS Windows Scripting Engine.
25
Set ObjectName = CreateObject("SAPI.SpVoice")
Auditory voice feedback during a test run, done by utilizing the Microsoft Speech API.
26
Set ObjectName = CreateObject( "UserAccounts.CommonDialog")
Object to provide users with a standard File Open dialog box
27
Set ObjectName = CreateObject("CDO.Message")
Windows CDO object is suitable for creating and sending automated emails.