Deep in to QTP
• Recap.
• Descriptive Programming.
• Objects and Their Identification.
• Data Table.
Descriptive Programming.
• Descriptive programming can be very useful if you want to perform an operation on an object that is not stored in the object repository.
• You can also use descriptive programming in order to perform the same operation on several objects with certain identical properties.
Syntax
MicClass("Property Name1:=Property Value1","Property Name 2:=Property Value 2")
Where MicClass is the mercury class of the test object, and Property Name:=Property Value is the description of the object, separated by commas.
Web Edits
Setting value to a Text Field
Browser("micClass:=Browser").Page("micClass:=Page").WebEdit("name:=txtOrganization").Set “Org 1”
Getting value from Text Field
sVariable=Browser(“micClass:=Browser”)Page(“micClass:=Page”).WebEdit “name:=j_username”).GetRoProperty(“value”)
WebLists
Setting value to a List Box
Browser("micClass:=Browser").Page("micClass:=page").WebList "name:=lstSelectedGroup").Select “Roles”
Getting value from List Box
sVariable=Browser(“micClass:=Browser”)Page(“micClass:=Page”).WebList("name:=lstSelectedGroup").GetRoProperty(“selection”)
Links
Clicking a Link
Browser("micClass:=Browser").Page("micClass:=Page").Link("name:=My Link","index:=0").Click
Web Button
Clicking a Web Button
Browser("micClass:=Browser").Page("micClass:=Page"). WebButton("name:=Login").Click
Web Elements
Browser("micClass:=Browser").Page("micClass:=Page"). WebElements.("name:=Save","index:=0").Click
Web Check Box
Checking a Check Box
Browser("micClass:=Browser").Page("micClass:=Page").WebCheckBox("name:=chkStatus","index:=1").Set "ON“
Selecting
Enables you to modify properties such as:
- Window nativeclass, title, and visible Dialog regexpwndtitle and regexpwndclass
- WinEdit nativeclass and index
- WinButton title and nativeclass Page micclass
- WebTable micclass, index, and html tag
- Image type, html tag, and alt
- WebElement micclass, innertext, and html tag
- WebRadioGroup name, micclass, and html tag
- WebEdit type, name, and micclass
- WebCheckBox type, micclass, and html tag
- WebList name, micclass, and html tag
- VbComboBox nativeclass and vbname
- VbRadioButton nativeclass and vbname
Handling Multiple Browsers
• When there are more than one browser, QTP finds it difficult to uniquely identify.
Browser("creationtime:=1").Page("micClass:=page").WebList("name:=lookupName").Select datatable("Division_Reader",globalsheet)
Data Table
• The Data Table is a Microsoft Excel-like sheet with columns and rows representing the data applicable to your test or component.
• Data Table has two types of data sheets—Global and Action.
Global Sheet
• You can use the columns in the global data sheet for Data Table output values or Data Table parameters in any action.
• This enables you to pass information between actions.
Action Sheets
• Each action also has its own sheet in the Data Table so that you can insert data that applies only to that action.
• Each time you add a new action to the test, a new actionsheetis added to the Data Table.
• Action sheets are automatically labeled with the exact name of the corresponding action.
Data Table
• Reading from Data table.
• Writing to Data Table.
• Importing data from an Excel Sheet.
• Using Data Table Scripting Methods
Reading from Data table
Syntax:
DataTable(
Filling the Web Edit with the Value from Data table
Browser("micClass:=Browser").Page("micClass:=Page").WebEdit("name:=txtStructure").Set DataTable("Division_Name",GlobalSheet)
Reading from Data table
Filling the WebList with the Value from Data table
Browser("creationtime:=1").Page("micClass:=page").WebList("name:=lookupName").Select DataTable("Division_Editor",GlobalSheet)
Writing to Data Table
Syntax:
DataTable.Value(
Example:
strValue=”Hello”
DataTable.Value(“Greeting","Global")=strValue
Controlling Data Table row
To get the row count
DataTable.GetRowCount
Example
intRows= DataTable.GetRowCount
Setting the Control to a particular row
To set the control to a particular row.
DataTable.
Example:
DataTable.GlobalSheet.SetCurrentRow(5)
Importing Data form an Excel sheet
Syntax:
DataTable.ImportSheet
File path: The full path of the Excel table
Sheet Source: Name or Index of the sheet
Sheet Destination: Name or index of the datatable.
Importing Data form an Excel sheet
Example:
DataTable.ImportSheet "J:\QTP\DataLoad.xls",4 ,"Global"
DataTable.ImportSheet "J:\QTP\DataLoad.xls","Issue" ,"Global"
Now to get back to some brasstacks (try this out).
No comments:
Post a Comment
Drop in your comments/ feedback