Wednesday, October 15, 2008

Technical - Automation

Automation – QTP related tips.

Sureshot things you should remember

• Browser(“micClass:=Browser”) Used to refer to the Browser object • Page(“micClas:=Page”)

Used to refer to the Page

Object • WebEdit(“name:=txtAssertion”) Used to refer to a textfield • Eg Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebEdit(“name:=ne wDescription”) Is used to refer to the textfield “newDescription” on the current page within the current browser. • To check the existence of the textfield Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebEdit(“name:=ne wDescription”).exist

To set the value of the textfield to “Abhilash”
Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebEdit(“name:=ne wDescription”).Set “Abhilash”

• To check for buttons
Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebElement(“innerte xt:=Save”, “html tag :=A”,”index:=1”).exist

• To click the Save button.
Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebElement(“innerte xt:=Save”, “html tag :=A”,”index:=1”).Click

• To select an option from the dropdown
Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebList(“name:=sel ectedEnumName”).select “Abhilash”

• To read the value of the textfield and store it in the variable
X X= Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebEdit(“name:=ne wDescription”).GetROProperty(“value”) (Any property can be used to access the value and store the same). • To select an option button. Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebCheckBox(“name =cmbCard”,”index:=2”).Set “ON”

• To derive the value from a datatable
Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebEdit(“name:=ne wDescription”).Set datatable(“ControlDescription”, globalsheet)
Where ControlDescription is the name of the column and globalsheet refers to the global sheet.

• Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebEdit(“name:=ne wDescription”).Set datatable(“ControlDescription”, Sheet2)

Will read the data from Sheet2 under ControlDescription column

• Code for synchronization
Environment.Value(“Class”) :=”creationtime:=1”
Set X = Browser(Environment.Value(“Class”)).Object
While (X.Busy = True OR X.ReadyStatus <> 4)
Set X = Browser(Environment.Value(“Class”)).ObjectWait 1
Wend

4 indicates Completed (hence checks for Not Completed to ensurecorrectness).

Setting value to a listbox

Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebList(“name:=selectedGroup”).Select “Abhilash”

Getting value from a listbox

X=Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebList(“name:=selectedGroup”).GetROProperty(“selection”)

Clicking a link
Browser(“micClass:=Browser”).Page(“micClass:=Page”).Link(“name:=Clickhere”,”index:=0”).Click

Clicking a Webbutton
Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebButton(“name:=Login”).Click
Or
Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebElements(“name:=Save”).Click
Reading from a datatableBrowser(“micClass:=Browser”).Page(“micClass:=Page”).WebEdit(“name:=txtName”).Set Datatable(“FirstNames”,GlobalSheet)

Populating the WebList with the datatable contents
Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebList(“name:=txtName”).Select Datatable(“FirstNames”,GlobalSheet)

Writing to datatable
Datatable(“FirstNames”,GlobalSheet) = “Abhilash”

To get the rowcount
intRow = DataTable.GetRowCount

To set the current row to 5
Datatable.GlobalSheet.SetCurrentRow(5)

Importing data from an Excel sheet
Datatable.ImportSheet , ,
Where is the Name or Index of the sheet is the name or index of the datatable.
Eg Datatable.ImportSheet “C:\Abhi\Abc.XLS”, 4,”Global”OrDatatable.ImportSheet “C:\Abhi\Abc.XLS”, “MYSheet”,”Global”


Environment Variables in QTP
ActionIteration : The action iteration currently running.
ControllerHostName : The name of the controller’s computer. This variable is relevant only when running as a GUI VUser from the LoadRunner controller.
GroupName : The name of the group in the running scenario. This variable is
relevant only when running as a GUI VUser from the LoadRunner controller.
LocalHostName: The local host name.
OS :The operating system.
OSVersion :The operating system version.
ProductDir :The folder path where the product is installed.
ProductName: The product name.
ProductVer :The product version.
ResultDir :The path of the folder in which the current test results are located.
ScenarioId: The identification number of the scenario.

No comments:

Post a Comment

Drop in your comments/ feedback

Calorie Calculator

Calculate how much you expend in 1 hour of your favorite exercise. Health Tips.
Powered By Blogger

Followers

Images - Decision tables

Images - Decision tables
Important image details for the Decision tables

Risk Management

Risk Management
Risk Management