Monday, November 9, 2015

How QTP and TestComplete Works

Suppose, we are given an application to automate. Let's start















1. Launch QTP.

2. Open Object Repository to add object (Test Time Object Property). You will see 'Agent Name" selected(Left) is a object of a WinEdit class. You can also see the "attached text" test time object property name and it's value "Agent Name:".




3. Dialog('Login").WinEdit("Agent Name:").Set "mercury"

This line says 'Enter "mercury" in "Agent Name:" exists on "Login" Dialog (Screen).

At run time QTP will search for object of WinEdit class whose run time object property is "attached text" and  value is "Agent Name:". If it finds successfully, result is 'Passed" else 'Failed".


How test automation tools work

Although, It very much depends on the tool.

Let's take an example:- What will you do If you are asked to find a person living in a big city and some information of that person are given to you?

City Name: ABC
Street Name: Mall Road
Block: A
House Number: 289
Name of the person: Saad

You will say this is very easy, Yes it is very easy but how it works?

Step1: Will go to that city.
Step2: Will search the street.
Step3: Will search the Block A.
Step4: Will search 289 house number.
Step5: Will call Mr. ABC.

Done!, But how? let me explain:-

You were given some set of properties (Test time Properties). In Step1 you searched for City, how did you know that this is the city you were looking for?

Because, City name which you were given(Test time property) and the city you are in (Run time property) are same. In each step you do the same.

Automation Tool work in the same way.


Friday, August 6, 2010

Checkproperty method in QTP

Checks whether the specified object property achieves the specified value within the specified timeout.

Syntax: object.CheckProperty (PropertyName, PropertyValue, [TimeOut])

Eg. 1. Check the status of page.

>Browser("micclass:=Browser prop").Page("micclass:=Page prop").Object.CheckProperty ("status","done",3000)

Eg. 2.Verify the text AutomationTest has been entered on the name textbox.

>Browser(“micclass:=Browser prop”).Page(“micclass:=Page prop”).WebEdit(“name of text box”).Set “AutomationTest”
sCheck=Browser(“micclass:=Browser prop”).Page(“micclass:=Page prop”).WebEdit(“textbox name”).CheckProperty “value”, “AutomationTest”

Monday, November 30, 2009

Check if a particuar text is present on page or not.

In few of scenarios we have to check that text is present on a page or not.

The following function will return True in case if text exists else function will return False.

'Create Page object
set objpage = Browser(“Browser Prop”).Page(“Page Prop”)

'Calling the function
msgbox VerifyTextOnPage(objParent ,”Test” )

Function VerifyTextOnPage(byval objpage , byval Textvalue )
On error resume next
Set oDesc= Description.Create()
oDesc(“micclass”).value=”WebElement”
oDesc(“html tag”).value=”.*[A-Za-z0-9].*”
oDesc(“outertext”).value =”.*[A-Za-z0-9].*”

'Create ALL child object
set collItems= objpage.ChildObjects(oDesc)

'Get all text from web page and store in a variable

For i=1 to collItems.count
OutPutText= OutPutText & collItems.Item(i).GetROProperty(“outertext”)
Next

'compare the text

If instr(1,lcase(OutPutText),lcase(Textvalue)) > 0 Then

' return true if found

VerifyTextOnPage= True
Else
rem return true if not found
VerifyTextOnPage= False
End If
On Error GoTo 0
End Function

Tuesday, November 24, 2009

Get Mouse Over Color of a Link

Using ReplayType setting to Mouse Events while firing an onMouseOver event on the link.

You will see that the hover event is triggered with the ReplayType set to Mouse Events:

Setting.WebPackage("ReplayType") = 2
Browser("xyz").page("xyz").Link("xyz").FireEvent "onMouseOver"
MsgBox Browser("xyz").page("xyz").Link("xyz").Object.currentStyle.color
Setting.WebPackage("ReplayType") = 1


Or

Function GetoverColor(oLink)
Setting.WebPackage("ReplayType") = 2
oLink.FireEvent "onMouseOver"
GetoverColor = oLink.Object.currentStyle.color
Setting.WebPackage("ReplayType") = 1
End Function