Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
intCount=Window("title:=Program Manager").WinListView("object
class:=SysListView32").GetItemsCount
msgbox intCount
Desktop.CaptureBitmap "C:\test.bmp"
FunctionRegexSelectQTP(Object, sPattern)
oRegExp.IgnoreCase = False
oRegExp.Pattern = sPattern
IfoRegExp.Test(arrAllItems(ix)) Then
Object.Select"#"& ix
ExitFunction
EndIf
Next
Object.Select"#0"
EndFunction
Or
Dim a,i
a=Browser().Page().Weblist(WebListName).GetItemsCount
Dlgname=Dialog("nativeclass:=#32770").GetROProperty("text")
msgbox Dlgname
lsbtnstatus=Dialog("text:="&Dlgname).winbutton("text:=OK").getroproperty("enabled")
If lsbtnstatus Then
msgbox "PASS"
End if
Or
set linkChildObj=B().p().childobjects(linkObj)
childCount=linkChildObj.count
End If
15 Write a program to Find image width and Height
imgCount = 0
Set obj = Browser("Software Quality Assurance").Page("micClass:=Page").Object.Images
cnt = obj.length
For i = 0 To cnt-1
'imgCount=imgCount+1
fn=Browser("Software Quality
Assurance").Page("micClass:=Page").Image("index:="&i).GetROProperty("file name")
fh=Browser("Software Quality
Assurance").Page("micClass:=Page").Image("index:="&i).GetROProperty("height")
fw=Browser("Software Quality
Assurance").Page("micClass:=Page").Image("index:="&i).GetROProperty("width")
Reporter.ReportEvent micGeneral, "Image Name: "&fn ,"Height "&fh&" Width "&fw
Next
Reporter.ReportEvent micGeneral, "Image Count",cnt-1
orFunction ScreenWidth()
ScreenWidth =Window("object class:=Shell_TrayWnd").GetROProperty("width")
EndFunction
FunctionScreenHeight()
ScreenHeight =Window("object class:=Shell_TrayWnd").GetROProperty("height")+
Window("object class:=Shell_TrayWnd").GetROProperty("y")
EndFunction
Set Object=Browser("").object
While Object.Busy=True
Wend
Set Object=nothing
orBrowser("title:=.*").Page("title:=.*").Sync
objIE.Refresh
lTime=Browser("Google").Page("Google").GetROProperty("load time")
lCount=Browser("Google").Page("Google").GetROProperty("number of
links")
iCount=Browser("Google").Page("Google").GetROProperty("number of
images")
Msgbox"Page Load Time="&lTime
Msgbox"Number of Links in Page="&lCount
Msgbox"Number of Images in Page="&iCount
Else
'Parameterization Block:
WithBrowser("title:=Welcome: Mercury Tours", "index:=0")
'Step 2
'Parameter 1: UserName
.WebEdit("name:=userName").Set Datatable("UserName", dtLocalSheet)
'Parameter 2: Password
.WebEdit("name:=password").Set Datatable("Password", dtLocalSheet)
.Image("name:=login").Click
EndWith
'Step 3
'If Find a Flight page appears, go back to Home
IfBrowser("title:=Find a Flight: Mercury Tours:", "index:=0").Exist(10) Then
'Step 4
Reporter.ReportEvent micPass, "Iteration "&
DataTable.LocalSheet.GetCurrentRow, _
"UserName: "& Datatable("UserName", dtLocalSheet) &" is valid"
Browser("title:=Find a Flight: Mercury Tours:",
"index:=0").Link("text:=Home").Click
Else
'Step 5
'Else, fail the iteration and return to the Home page
Reporter.ReportEvent micFail, "Iteration "&
DataTable.LocalSheet.GetCurrentRow, _
"UserName: "& Datatable("UserName", dtLocalSheet) &" is invalid"
Browser("title:=Sign-on: Mercury Tours", "index:=0").Link("text:=Home").Click
EndIf
27 Write a program to Read data from all sheets and all parameters of the
excel file
Set excel=createobject("excel.application")
excel.Visible=True
Set workbook=excel.Workbooks.Open("D:\excel.xls")
Or
'Make sure that you have created an excel file before executing
the script .
'Use the path of excel file in the below code.
'Also make sure that your excel file is in Closed state.
myxl.Workbooks.Open "D:\parameter.xls"
myxl.Application.Visible = true
'contents of sheet1
'Uname Pwd
'------------ ------------
'qtpworld.com qtp
'admin qtp
' qtp
'admin
'abcd abcd
'Launch Gmail
Systemutil.Run "iexplore.exe","http:\\www.gmail.com"
Username=mysheet.cells(i,1).value
Password=mysheet.cells(i,2).value
wait 1
Next
'Close Excel
myxl.Application.Quit
'Release the objects
Set mysheet =nothing
Set myxl = nothing
MsgBox objAdRs.fields(4).name
While objAdRs.EOF=false
For i=0 to objAdRs.Fields.count
Msgbox objAdRs.fields(i)
Next
objAdRs.moveNext
Wend
If Err<>0 Then
Reporter.ReportEvent micFail,Open Recordset, Error has occured.Error Code :
& Err
Set obj_UDF_getRecordset = Nothing
Exit Function
End If
objAdCon.Close
Set objAdCon = Nothing
End Function
z=1
'Loop for finding start and end position
For i=1 to (Occurrence+1)
y = Instr(z, RequiredLine , "," , 1)
z=y+1
Next
EndPosition = (y-StartPosition)
End Function
Purpose:
To get the number of rows and number of columns of a table from a page
Script:
Set MyTable=Browser("Gmail: Email from Google").Page("Gmail - Inbox").WebTable("html
tag:=TABLE","name:=t")
RC=MyTable.RowCount
CC=MyTable.ColumnCount(1)
Print "RC " & RC
Print "CC " & CC
Purpose:
To get the cell data of a table from a page
Method used is GetCellData(Row#,Col#)
Script:
Set Text = Browser("").Page("").WebTable("").GetCellData(1, 1)
MsgBox "text contains" & Text
Example:
Set oTable=Browser("").Page("").WebTable("")
For i=1 to RC
CC=oTable.ColumnCount(i)
For j=1 to CC
CData=oTable.GetCellData(i,j)
Print "CData " & CData
Next
Next
Purpose:
To the required cell data from a web table and write these values to an excel sheet
Script:
For i=1 to RC
Datatable.GetSheet("MySheet").SetCurrentRow(i)
CC=oTable.ColumnCount(i)
For j=1 to CC
CData=oTable.GetCellData(i,j)
DataTable.GetSheet("MySheet").GetParameter(j).value=CData
Print "CData " & CData
Next
Next
For i=1 to CC
ColName=oTable.GetCellData(1,i)
Print "ColName "& ColName
DataTable.GetSheet("MySheet").AddParameter ColName,""
Next
For i=1 to RC
Datatable.GetSheet("MySheet").SetCurrentRow(i)
CC=oTable.ColumnCount(i)
For j=1 to CC
CData=oTable.GetCellData(i,j)
DataTable.GetSheet("MySheet").GetParameter(j).value=CData
Print "CData " & CData
Next
Next
PCMySheet=DataTable.GetSheet("MySheet").GetParameterCount
RCMySheet=DataTable.GetSheet("MySheet").GetRowCount
Purpose:
To get the number of web tables existing on a page
To the get all web tables names, text, rowcount, columncount
Script:
Set ObjTable=Description.Create
ObjTable("html tag").value="TABLE"
ObjTable("text").value=".*"
Next
Purpose:
Getting all the information from a known table (like RowCount, ColumnCount, CellData and so on)
Why this script is for:
This script helps to work on particular table to get all the info of that table so as to write data into an excel
or passing particular cell data as parameter to the running test script or Verifying the table data if it is as
per the requirements.
Script:
Set MyTable=Browser("Gmail: Email from Google").Page("Gmail - Inbox").WebTable("html
tag:=TABLE","name:=t")
RC=MyTable.RowCount
CC=MyTable.ColumnCount(1)
Print "RC " & RC
Print "CC " & CC
DataTable.AddSheet "WebTable"
For i=1 to CC
CName=MyTable.GetCellData(1,i)
DataTable.GetSheet("WebTable").AddParameter CName,""
Next
For i=1 to RC
CC=MyTable.ColumnCount(i)
For j=1 to CC
MyData=MyTable.GetCellData(i,j)
Print "MyData " & MyData
Next
Next
Set ObjTable=Description.Create
ObjTable("html tag").value="TABLE"
ObjTable("text").value=".*"
Set ObjTable=Description.Create
ObjTable("html tag").value="TABLE"
ObjTable("text").value=".*"
Next
Simmilary, in Gmail, there is InBox and if we want to get the exact row number where a specific mail
(mail header) exists, then we could make use of the above code.
Purpose:
Retrieving all Web Table Names from a page
Script:
Set oTable =B().p().WebTable(html tag:=TABLE).ChildObjects
Msgbox oTable .count
For i=0 to oTable .count-1
Msgbox I && oTable (i).GetROProperty(name)
Next
Next
DataTable.AddSheet "MySheet"
Set oTable=Browser("Gmail: Email from Google").Page("Gmail - Inbox").WebTable(t")
RC=oTable.RowCount
CC=oTable.ColumnCount(1)
Print "RC " & RC
Print "CC " & CC
For i=1 to CC
ColName=oTable.GetCellData(1,i)
Print "ColName "& ColName
DataTable.GetSheet("MySheet").AddParameter ColName,""
Next
sColor = objWebEl.currentStyle.color
sBackgrColor = objWebEl.currentStyle.backgroundColor
sFontSize = objWebEl.currentStyle.fontSize
sFontStyle = objWebEl.currentStyle.fontStyle
sFontFamily = objWebEl.currentStyle.fontFamily
sFontWeight = objWebEl.currentStyle.fontWeight
36 Write a program to Print results in a HTML format
Procedure to create the QTP results in
HTML format
Sunday, 15 March 2009 04:26
set radiobtn =
browser(br).page(pg).webradiogroup(rb).GetROProperty("items count")
Print " total Radio buttons are" & radiobtn 'this gives me total
no of radio button as 9
For i = 1 to radiobtn
mypg.webradiogroup(firdtrb).select "2"
End if
set ig = description.create() 'this will click on image after
selecting radio button & just reload page
ig("name").value = "AU_tcpolicy_img"
ig("html tag").value = "INPUT"
mypg.image(ig).click
radiobtn = radiobtn +1
38 Write a program to Read all the items from a services window
From QTP point of view there are few tasks where WSH could be very handy:
objshell.Run "H:\WSH_QTP\test_1.vbs"
objShell.exec ("calc")
But WSH does not run the below statement, giving an error not a WIN32 application
objShell.Exec "H:\WSH_&_QTP\test1.vbs"
As per my understanding, RUN is used to run windows specific applications and EXEC to execute a
statement.
Or
End Function
Or
1. Dim pTitle
2.
3. '***************************************************
4. Function CompareBitmap(ActualBmp, ExpectedBmp)
5.
6.
7. Set fCompare = CreateObject("Mercury.FileCompare")
8.
9.
10. If fCompare.IsEqualBin(ExpectedBmp, ActualBmp, 0, 1) Then
11.
12. Reporter.ReportEvent micPass,"Bitmap Verification",ActualBmp&"and"&ExpectedBm
p&" are same"
13. CompareBitmap=True
14. Else
15. Reporter.ReportEvent micFail,"Bitmap Verification",ActualBmp&"and"&ExpectedBm
p&" are not same"
16. CompareBitmap=False
17. End If
18.
19.
20. End Function
21. '***************************************************
22. 'Calling the Function
'*********************************************************************
If qtRepositories.Find(RepPath) = -1 Then
qtRepositories.Add RepPath, 1 ' Add the Object Repository to the current action
End If
qtApp= Nothing
qtRepositories= Nothing
'*********************************************************************
'*********************************************************************
If rPosition<>-1 then
End if
qtApp= Nothing
qtRepositories= Nothing
0
inShare
Most of the times, when you are creating test scripts or are designing a new QTP
Framework, you would be trying to come up with reusable functions which you would have
to store in the function library. Now, in order to use this function library with multiple test
cases, you need to associate this function library with your scripts. This article explains
the 4 methods that will help you in associating the function libraries in QTP Test
Cases.
Based on the type of framework you are using, you can use any of the following methods to
associate function libraries to your QTP Script -
1) By using File > Settings > Resources > Associate Function Library option in
QTP.
2) By using Automation Object Model (AOM).
3) By using ExecuteFile method.
4) using LoadFunctionLibrary method.
Lets see in detail how each of these methods can be used to map function libraries to your
test scripts.
1. Using File > Settings > Resources > Associate Function Library option from the Menu bar
This is the most common method used to associate a function library to a test case. To use
this method, select File > Settings option from the Menu bar. This will display the Test
Settings window. Click on Resources from the left hand side pane. From the right hand side
pane, click on the + button and select the function library that needs to be associated with
the test case.
QTP AOM is a mechanism using which you can control various QTP operations from outside
QTP. Using QTP Automation Object Model, you can write a code which would open a QTP
test and associate a function library to that test.
Example: Using the below code, you can open QTP, then open any test case and associate a
required function library to that test case. To do so, copy paste the below code in a notepad
and save it with a .vbs extension.
1 'Open QTP
2 SetobjQTP = CreateObject("QuickTest.Application")
3 objQTP.Launch
4 objQTP.Visible = True
10 'If the library is not already associated with the test case, associate it..
End
13
1 'Action begins
2 ExecuteFile "C:\YourFunctionLibrary.vbs"
5 '.....
2 '.....
6
7 'Other logic for your action would come here
8 '.....
This was all about the different ways using which you can associate function libraries to QTP
Scripts. What are your views on this article? Can you think of any other points which I have
missed and can be added here? Please let us know your views using the comments section.
Happy Reading.. :)
Precondition:-
To understand this topic you need to have knowledge on creating and using
recovery scenarios.
In this document I am discussing about how to add, remove recovery scenario files (.QRS)
to a test and after adding how to activate, deactivate and renumbering the order to
execute recovery scenarios.
For example I have a recovery scenario file with the name of sample .qrs. Assume that in
this recovery file I have two recoveries with the names loginPop, RunErr. (All of you know
that one file can have multiple recoveries). Now if i want to use that file in my test then I
have to use following script.
'*******************************************************************
' Create the Application object
Set qtApp = CreateObject("QuickTest.Application")
' Return the Recovery object for the current test
Set qtTestRecovery = qtApp.Test.Settings.Recovery
' Add the " loginPop " scenario as the first scenario
qtTestRecovery.Add "E:\Sudhakar\Recoveryfiles\sample.qrs", " loginPop ", 1
' Add the " RunErr " scenario as the second scenario
qtTestRecovery.Add "E:\Sudhakar\Recoveryfiles\sample.qrs", " RunErr ", 2
' Iterate the scenarios
For intIndex = 1 To qtTestRecovery.Count
' Enable each Recovery Scenario (Note: the 'Item' property is default and can be omitted)
qtTestRecovery.Item(intIndex).Enabled = True
Next
' Enable the recovery mechanism (with default, on errors, setting)
qtTestRecovery.Enabled = true
'Ensure that the recovery mechanism is set to be activated only after errors
qtTestRecovery.SetActivationMode "OnError"
Set qtApp = Nothing ' Release the Application object
Set qtTestRecovery = Nothing ' Release the Recovery object
'*******************************************************************
With the above code automatically the recovery scenarios will be added to the specified
test. After adding the scenarios if you want to control the scenario like changing the
scenario status, to get the scenario name, to activate or deactivate we have to use recovery
object (one of the Utility object).
Recovery Object
It is an utility object to control the recovery scenario mechanism programmatically during
the run session.
Its having some properties and methods to control the scenarios.
Associated Methods
1. Activate Method:
Explicitly activates the recovery scenario mechanism at a specific point in the run.
Note: The Activate method only works if the recovery mechanism is enabled, and only
activates those recovery scenarios that are currently enabled.
If the recovery mechanism is currently disabled, the Activate method does not activate
any recovery scenarios. You can use the Recovery object's Enabled property to change the
status of the recovery mechanism.
Ex:- Recovery.Activate
2. GetScenarioName Method:
Retrieves the name and source file of a recovery scenario, according to the specified
position in the list of recovery scenarios associated with the test.
Ex:- Recovery.GetScenarioName Position, out_ScenarioFile, out_ScenarioName
Msgbox(out_ScenarioFile)
Msgbox(out_ScenarioName)
3. GetScenarioPosition Method
Returns the index position of a recovery scenario in the list of recovery scenarios associated
with the test, according to the specified name and source file.
Ex:- Recovery.GetScenarioPosition (ScenarioFile, ScenarioName)
4. GetScenarioStatus Method
Returns the status of a recovery scenario (True = enabled or False = disabled), according to
the specified index position in the list of recovery scenarios associated with the test.
Ex:- Recovery.GetScenarioStatus Position
SetScenarioStatus Method
Enables or disables the specified recovery scenario, according to its index position in the list
of recovery scenarios associated with the test.
Ex:- Recovery.SetScenarioStatus Position, Status
Associated Properties
Count Property
Returns the number of recovery scenarios associated with the current test.
Ex:- msgbox Recovery.Count
Enabled Property
Recovery default property. Retrieves or sets the status of the recovery scenario mechanism
for the current test.
Ex:- Recovery.Enabled =Status
'********************************************************************
Sample Script
Or
qtResultsOpt.ResultsLocation = QTPResultspath
App.Test.Run qtResultsOpt
'App.Test.Run
'___________________CODE________________
MasterFolder = "C:\TestAutomation"
Dim App, qtResultsOpt, fso, f
Set App = CreateObject("QuickTest.Application")
If App.Launched = False Then
App.Launch
End If
App.Visible = True
App.Options.Run.ImageCaptureForTestResults = "Always"
App.Options.Run.RunMode = "Fast"
App.Options.Run.ViewResults = True
App.Open MasterFolder&"\Tests\EFiles",False,False
App.Test.Settings.Resources.Libraries.RemoveAll
App.Test.Settings.Resources.Libraries.Add MasterFolder&"\Business Functions\TestScripts.vbs"
App.Test.Run qtResultsOpt
'App.Test.Run
Set App = nothing
Set qtResultsOpt = Nothing
RunAction "Action1[test1]",oneIteration.
By using this u can call the test1 script. There is no
other way than this.
48 Write your own standard checkpoint
49 Write your own synchronization function
SystemUtil.Run "iexplore.exe", "http://www.google.com"
Browser("Google").Page("Google").Sync
Browser("Google").Navigate "http://www.cnn.com"
Browser("Google").Page("CNN.com - Breaking News,").Sync
Wait 10 ' we can read the latest news
Browser("Google").Back
or
Browser("BMC Remedy Mid Tier 7.1").Page("Home Page
(Search)").WebElement("Logout").WaitProperty "visible", true, 20000
50 Write a program to Read menu names
Menu Object
Menu object applies only window based applications. Default Method For Menu is
"Select"
Ex:
For i = 0 to (CheckBoxCnt - 1)
objWebCheckBox(i).Set "ON"
Next
53 Write a program to Check whether we can select multiple items in the
listbox
Dim a,i
a=Browser().Page().Weblist(WebListName).GetItemsCount
If a=15 Then
else
End If
55 Write a program to Check whether items in the page are aligned properly
Dim a
Set a=createobject("Quicktest.application")
b=a.getassociatedaddinsfortest("D:\test4")
For each c in b
print c
Next
or
TO FIND ADD-IN FOR CURRENT TEST
Dim a
Set a=createobject("Quicktest.application")
b=a.test.getassociatedaddins()
For each c in b
print c
Next
Option Explicit
Dim ObjBrow,ObjName,ObjBrowName
Set ObjBrow = Description.Create()
ObjBrow(micClass).values = "Browser"
ObjName = Desktop.ChildObject(ObjBrow)
msgbox = ObjName.count
for i = 0 to ObjName.count
ObjBrowName = ObjName(i).getROproperty("Name")
msgbox(ObjBrowName)
ObjName(i).close
Next
Or
Browser("creationtime:=0").Close
Loop
61 Write a program to Check whether a window is in minimized or
maximized
a=window("Flight Reservation").GetROProperty("minimizable")
b=window("Flight Reservation").GetROProperty("maximizable")
If a=true Then
else
If b=true Then
else
End If
a = Window("Microsoft Word").GetROProperty("width")
b = Window("Microsoft Word").GetROProperty("height")
a = a - 50
b = b - 50
a.load "D:\test.xml"
childelength =child.length
x=child.item(i).text
print x
Next
print a
'buttonprop.MandatoryProperties.Remove("x")
a2=buttonprop.MandatoryProperties.Find("y")
print a2
c = buttonprop.AssistiveProperties.Find("window id")
print c
buttonprop.AssistiveProperties.Add("x")
d = buttonprop.AssistiveProperties.Find("x")
print d
a.options.Run.RunMode="Normal"
a.options.Run.ViewResults="true"
a.options.Run.ImageCaptureForTestResults="OnError"
Before Execution
After Execution
reporter.ReportPath = "D:\"
msgbox Environment("value")
Environment("value")=10
msgbox Environment("value")
a.options.run.MovieCaptureForTestResults="OnWarning"
webutil.DeleteCookies
Environment("value")=10
msgbox Environment("value")
Set IE CreateObject("InternetExplorer.Application")
IE.Visible True
IE.Navigate http://www.google.com
http://www.wiziq.com/tutorial/53994-QTP-Scripting
set b=a.opentextfile("F:\test.csv")
p=1
x=b.readline
datatable.GetSheet(1).setcurrentrow(p)
datatable.Value("items",1)=x
p=p+1
wend
or
Set a=createobject("scripting.filesystemobject")
set readitems=a.opentextfile("F:\test.csv")
c=readitems.readall
print c
For i = 1 to a
Next
Or
s=Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebTable("Atlanta to Las
Vegas").GetROProperty("text")
msgbox s
Program
a=Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").Link("your
destination").getroproperty("background color")
print a
b = Window("Program Manager").WinListView("SysListView32").GetROProperty("width")
print "The Scree Resolutuion is " & a & " x " & b
Program
a = Browser("Welcome: Mercury Tours").Page("Sign-on: Mercury Tours").Image("sign-
on").GetROProperty("alt")
If a = b Then
else
End If
a="D:\open.tsr"
b="D:\insert.tsr"
c="D:\delete.tsr"
repositoriescollection.Add(a)
repositoriescollection.Add(b)
repositoriescollection.Add(c)
Window("Flight Reservation").WinButton("FLIGHT").Click
repositoriescollection.Remove(1)
Program
executefile ("D:\msg.vbs")
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("FLIGHT").Click
MyCurrentStatus=Recovery.Enabled
Recovery.Enabled=True
End If
Recovery.enabled=False
Window("Flight Reservation").WinButton("Button_5").Click
Window("Flight Reservation").WinButton("FLIGHT").Click
Program
reporter.ReportEvent micDone,"test(Object)","Test Report(Details)"
Program
b = window("Flight Reservation").Winbutton(a).GetROProperty("Enable")
Window("Flight Reservation").WinButton(a).Click
print b
Program
s=Window("Flight Reservation").GetROProperty("hwnd")
window("hwnd:="&s).close
(or)
Window("Flight Reservation").close
Window("Flight Reservation").Activate
ret = 0
If ret Then
For n = 1 To cnt
Path = menuObj.BuildMenuPath(itemPath, n)
Next
End If
End Function
64 Check whether a check button is selected or not
Program
Window("Flight Reservation").Dialog("Open Order").Activate
msgbox status
Program
a = Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("selection")
Program
If a=15 Then
print "Edit box allows exactly 15 characters"
else
End If
Program
Dim a
Set a=createobject("Quicktest.application")
b=a.getassociatedaddinsfortest("D:\test4")
For each c in b
print c
Next
or
TO FIND ADD-IN FOR CURRENT TEST
Dim a
Set a=createobject("Quicktest.application")
b=a.test.getassociatedaddins()
For each c in b
print c
Next
Program
a=window("Flight Reservation").GetROProperty("minimizable")
b=window("Flight Reservation").GetROProperty("maximizable")
If a=true Then
else
End If
If b=true Then
else
End If
70 Check window resizable
Program
Window("Microsoft Word").Activate
a = Window("Microsoft Word").GetROProperty("width")
b = Window("Microsoft Word").GetROProperty("height")
a = a - 50
b = b - 50
Program
a = Window("Local Disk (D:)").WinListView("SysListView32").GetItemsCount
For i = 0 to a-1
Next
73 Read elements in the XML file
Program
Set a=createobject("msxml2.domdocument")
a.load "D:\test.xml"
childelength =child.length
x=child.item(i).text
print x
Next
Program
a = Browser("Register: Mercury Tours").Page("Welcome: Mercury Tours").Link("Business Travel @
About.com").GetROProperty("font")
print a
75 Check Marquee
Program
print browser("Browser").Page("Page").WebElement("Born to Lead the
World").GetROProperty("innertext")
Program
Dim mytime
mytime = now
a = hour(mytime)
For i = 1 to 24
If a = i Then
print stack
End If
Next
Set app=createobject("QuickTest.Application")
set ident=app.Options.ObjectIdentification
set buttonprop= ident.item("WinButton")
a =buttonprop.MandatoryProperties.Find("text")
print a
buttonprop.MandatoryProperties.Add("y")
a1=buttonprop.MandatoryProperties.Find("y")
print a1
'buttonprop.MandatoryProperties.Remove("x")
a2=buttonprop.MandatoryProperties.Find("y")
print a2
c = buttonprop.AssistiveProperties.Find("window id")
print c
buttonprop.AssistiveProperties.Add("x")
d = buttonprop.AssistiveProperties.Find("x")
print d
Program
Set a=createobject("QuickTest.Application")
a.options.Run.RunMode="Normal"
a.options.Run.ViewResults="true"
a.options.Run.ImageCaptureForTestResults="OnError"
Before Execution
After Execution
Program
print browser("Browser").Page("Page").WebElement("Born to Lead the
World").GetROProperty("innertext")
reporter.ReportEvent micDone, "Pass","Marquee Captured"
reporter.ReportPath = "D:\"
Program
MsgBox(environment("prak"))
environment("prak") = 20
MsgBox(environment("prak"))
Program
msgbox Environment("value")
Environment("value")=10
msgbox Environment("value")
84 Clear the cache in the webpage
webutil.DeleteCookies
a.options.run.MovieCaptureForTestResults="OnWarning"
VB QUESTIONS
For i = 1 to 1000
If len(i) = 3 Then
a = ( i / 100)
a = int (a)
b = ( i / 10)
b = int (b)
c = ( b mod 10)
c = int (c)
d = i mod 10
d = int (d)
j = (a^3) + (c^3) + (d^3)
If i = j Then
print i
End If
End If
Next
reverse=strreverse(MyStr)
s=strcomp(MyStr,reverse)
If s=0 Then
print "palindrome"
else
End If
b = strreverse(a)
print "Reversed String is " & b
else
End If
If (i mod 7) =0 Then
print i
End If
Next
91 Print the list of ODD numbers.
Program
print "Odd Number are as follows"
For i=1 to 10
print i
End If
Next
For i=1 to 10
If (i mod 2) = 0 Then
print i
End If
Next
Output
Dim a,b,c,d,e,i
For j = 1 to 50
b=0
For i = 1 to J-1
a = J mod i
If a = 0 Then
b=b+i
End If
Next
If b = J Then
print J
End If
Next
b = len(a)
b =len(str)
c=0
For i=1 to b
d=asc(mid(a,i,1))
c=c+1
End If
Next
print c
If a>100 Then
else
End If
If a>b Then
print a & " is greater than " & b
else
End If
else
End If
b=1
For i=1 to 10
t=a+b
a=b
b=t
print t
Next
100 Write a program to find whether the given string is equal or not.
Program
For I = 0 to 2
For J = 0 to 2
Next
Next
For I = 0 to 2
For J = 0 to 2
Next
Next
For I = 0 to 2
For J = 0 to 2
Next
Next
For I = 0 to 2
For J = 0 to 2
MsgBox C(i,j)
Next
Next
Input
6
5
For I = 0 to 2
For J = 0 to 2
Next
Next
For I = 0 to 2
For J = 0 to 2
Next
Next
For I = 0 to 2
For J = 0 to 2
Next
For I = 0 to 2
For J = 0 to 2
MsgBox C(i,j)
Next
Next
Input
2
1
For I = 0 to 1
For J = 0 to 1
Next
Next
For I = 0 to 1
For J = 0 to 1
Next
Next
For I = 0 to 1
For J = 0 to 1
Sum = 0
For K = 0 to 0
C(I,J) = Sum
Next
Print C(I,J)
Next
Next
Input
1
104 Input to the Function is Window Name. The Function
should
Check Whether the Window exists or not. If exists activate it or else
exit.
Program
Function windowname(wname)
Window("Flight Reservation").Activate
else
End If
End If
End Function
windowname("Flight Reservation")
Call tp(fun)
Function tp(fun1)
repositoriescollection.Add("D:\insert.tsr")
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button_2").Click
Window("Flight Reservation").WinButton("FLIGHT").Click
repositoriescollection.RemoveAll
else
repositoriescollection.Add("D:\openorder.tsr")
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").WinButton("Button_2").Click
End If
End Function
a.load "D:\insert.tsr"
Set z = a.getallobjects(Window)
For k = 0 to z.count-1
Set y = z.item(k)
print a.GetLogicalName(y)
Next
Set z = nothing
Set y = nothing
Set k = nothing
For j = 0 to ubound(dataentry)
Set b = a.getallobjectsbyClass(dataentry(j))
For i = 0 to b.count-1
Set c = b.item(i)
d = a.getlogicalname(c)
print d
Next
Set b = nothing
Set c = nothing
Set d = nothing
Set e = nothing
Next
107 From the popup message, get the text only and display the main
message only.
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
End If
108 From the frame error message, get the text and display only the
main message.
Program
a=Browser("Register: Mercury Tours").Page("Register: Mercury Tours").WebElement("Note: The
confirmed password").GetROProperty("innertext")
print a
109 What is the statement used for comparing 2 strings and print the
string is equal or not?
Program
Dim A, B
A = InputBox("Enter First Name")
B = InputBox("Enter Second Name")
Result = strcomp(A , B)
If Result = 0 Then
print "strings are Equal"
else
print "strings are Not Equal"
End If