Site icon Tutorial

Automation Testing Tutorial | GUI Objects

GUI Objects

There are various GUI objects with which QTP interacts during the script execution. Hence it is important to know the basic methods for the key GUI objects using which we will be able to work on it effectively.

Text Box

Below are the methods using which we access text box during Run Time.

Example:

Browser(“Math Calculator”).Sync

Set Obj = Browser(“Math Calculator”).Page(“SQR Calc”).WebEdit(“n”)

‘Clicks on the Text Box

Obj.Click

‘Verify if the Object Exist – Returns Boolean value

a= obj.Exist

print a

‘Set the value

obj.Set “10000” : wait(2)

‘Get the Runtime Object Property – Value of the Text Box

val = obj.GetROProperty(“value”)

print val

‘Get the Run Time Object Property – Visiblility – Returns Boolean Value

x= Obj.GetROProperty(“visible”)

print x

 

Check Box

Following are some of the key methods with which one can work with Check Box.

Example:

‘To Check the Check Box

Set Obj = Browser(“Calculator”).Page(“Gmail”).WebCheckBox(“PersistentCookie”)

Obj.Set “ON”

‘To UnCheck the Check Box

Obj.Set “OFF”

‘Verifies the Existence of the Check box and returns Boolean Value

val = Obj.Exist

print val

‘Fetches the Name of the CheckBox

a= Obj.GetROProperty(“name”)

print a

‘Verifies the visible property and returns the boolean value.

x = Obj.GetROProperty(“visible”)

print x

 

Radio Button

Following are some of the key methods with which one can work with Radio Button.

Example:

‘Select the Radio Button by name “YES”

Set Obj = Browser(“Calculator”).Page(“Forms”).WebRadioGroup(“group1”)

Obj.Select(“Yes”)

‘Verifies the Existence of the Radio Button and returns Boolean Value

val = Obj.Exist

print val

‘Returns the Outerhtml of the Radio Button

txt = Obj.GetROProperty(“outerhtml”)

print text

‘Returns the boolean value if Radio button is Visible.

vis = Obj.GetROProperty(“visible”)

print vis

 

Combo Box

Following are some of the key methods with which one can work with Combo Box.

Example:

‘Get the List of all the Items from the ComboBox

Set ObjList = Browser(“Math Calculator”).Page(“Statistics”).WebList(“class”)

x = ObjList.GetROProperty(“all items”)

print x

‘Get the Number of Items from the Combo Box

y = ObjList.GetROProperty(“items count”)

print y

‘Get the text value of the Selected Item

z = ObjList.GetROProperty(“text”)

print z

Buttons

Following are some of the key methods with which one can work with Buttons.

Example:

‘To Perform a Click on the Button

Set obj_Button = Browser(“Math Calculator”).Page(“SQR”).WebButton(“Calc”)

obj_Button.Click

‘To Perform a Middle Click on the Button

obj_Button.MiddleClick

‘To check if the button is enabled or disabled.Returns Boolean Value

x = obj_Button.GetROProperty(“disabled”)

print x

‘To fetch the Name of the Button

y = obj_Button.GetROProperty(“name”)

print y

 

Test Your Automation Testing Skills By Taking Our Free Practice Tests On This Link

Exit mobile version