Tuesday, 6 July 2021

Sample QTP scripts

'Code for printing the files in a folder
Option Explicit
Dim fso,fld,sFiles,sFile
Set fso=CreateObject("Scripting.FileSystemObject")
Set fld=fso.GetFolder("C:\Documents and Settings\Administrator\Desktop\Project")
Set sFiles=fld.Files
For each sFile in sFiles
  print sFile.Name
Next
Set fso=nothing


‘++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'Code for Action Parameters by using Input,Output Parameters
a=10
b=20
Datatable.LocalSheet.AddParameter "Sum",""
Datatable.LocalSheet.AddParameter "Diff",""
Datatable.LocalSheet.AddParameter "Prod",""
RunAction "Action2", oneIteration,a,b,sum1,diff1,prod1
'RunAction "Action2", oneIteration,a,b,Datatable(1,2),Datatable(2,2),Datatable(3,2)
wait 3
Msgbox "Sum:   "&sum1
Msgbox "Diff:   "&diff1
Msgbox "Prod:   "&prod1


'Code for creating input,output parameters
Option Explicit
Dim n1,n2,sum,diff,prod
n1=Parameter("Num1")
n2=Parameter("Num2")
sum=n1+n2
diff=n2-n1
prod=n1*n2
Parameter("s")=sum
Parameter("d")=diff
Parameter("p")=prod


Code for actions
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").WinEdit("Agent Name:").Set "jampani007" @@ hightlight id_;_1049510_;_script infofile_;_ZIP::ssf1.xml_;_
Dialog("Login").WinEdit("Agent Name:").Type  micTab @@ hightlight id_;_1049510_;_script infofile_;_ZIP::ssf2.xml_;_
Dialog("Login").WinEdit("Password:").SetSecure "4a3f0a7be1e01cd14cdbff178464bf5992d35800" @@ hightlight id_;_393928_;_script infofile_;_ZIP::ssf3.xml_;_
Dialog("Login").WinEdit("Password:").Type  micReturn @@ hightlight id_;_393928_;_script infofile_;_ZIP::ssf4.xml_;_


RunAction "Copy of Create_order", oneIteration
RunAction "Fax_order", oneIteration
RunAction "Copy of Logout", oneIteration


'Code for finding the Broken links by using child objects
Option Explicit
Dim brlnk,desc,cnt,i,coll,oShell,link
SystemUtil.Run "www.yatra.com"
Set oShell=CreateObject("wscript.shell")
Set desc=Description.Create
desc("html tag").Value="A"
Set coll=Browser("Yatra.com My Bookings").Page("Yatra.com My Bookings").ChildObjects(desc)
cnt=coll.count
oShell.popup "No of Links:   "&cnt,2,"Links Info"
For i=0 to cnt-1
Set coll=Browser("Yatra.com My Bookings").Page("Yatra.com My Bookings").ChildObjects(desc)
'link=coll(i).GetRoProperty("name")
oShell.popup coll(i).GetRopRoperty("name"),1,"Link Info"
coll(i).click
If (coll(i).GetRoProperty("title")="The page cannot be disp") Then
brlnk=brlnk+1
End If
Browser("Yatra.com My Bookings").Back
Next
Msgbox "No of Broken Links:   "&brlnk
Set oShell=nothing
'Code for Built-In Enviroment Variables to read system info
Msgbox "Computer Name:    "&Environment.Value("LocalHostName")
Msgbox "Operating System:    "&Environment.Value("OS")
Msgbox "OS Version:    "&Environment.Value("OSVersion")
Msgbox "Action Name:    "&Environment.Value("ActionName")
Msgbox "Action Iteration:    "&Environment.Value("ActionIteration")
Msgbox "TestName:    "&Environment.Value("TestName")
Msgbox "Test Iteration:    "&Environment.Value("TestIteration")
Msgbox "ProductName:    "&Environment.Value("ProductName")
Msgbox "Product Version:    "&Environment.Value("ProductVer")
Msgbox "Product Dir:    "&Environment.Value("ProductDir")
Msgbox "Test Dir:    "&Environment.Value("TestDir")
'Code for capturing the text forom a webpage by using GetCellData()
Option Explicit
Dim rowcnt,colcnt,rowno,colno,celldata,oShell
Set oShell=CreateObject("wscript.shell")
rowcnt=Browser("IN Offers E Mail, News,").Page("IN Offers E Mail, News,").WebTable("index:=2").RowCount
'Msgbox "Row count:    "&rowcnt
oShell.popup "Row count:    "&rowcnt,2,"Row Info"
For rowno=1 to rowcnt
 colcnt=Browser("IN Offers E Mail, News,").Page("IN Offers E Mail, News,").WebTable("Index:=2").ColumnCount(rowno)
' Msgbox "Column Count:  "&colcnt
oShell.popup "Column count:    "&colcnt,2,"Col Info"
             For colno=1 to colcnt
                 celldata=Browser("IN Offers E Mail, News,").Page("IN Offers E Mail, News,").WebTable("Index:=2").GetCellData(rowno,colno)
 If (celldata<>"") Then
 oShell.popup  celldata,1,"Cell Info"
 End If
   Next
Next


'Code for capturing the text from a window by using GetVisibleText()
Option Explicit
Dim str1,str2,pos,res
str1=window("Flight Reservation").Dialog("About Flight Reservation").GetVisibleText()
Msgbox str1
str2="Version 4.0"
pos=Instr (1,str1,str2,VBTextCompare)
Msgbox pos
If (pos<>0) Then
res=Mid(str1,pos,11)
   If (res=str2) Then
Msgbox "The string exist:     "&res
Else
Msgbox "The string does not exist:   "&pos
End If
End If
'Code for capturing the text from a webpage by using GetCellData()
Option Explicit
Dim web,rowcnt,colcnt,rowno,colno,celldata,cnt,coll,oShell,i
Set oShell=CreateObject("wscript.shell")
Set web=Description.Create
'web("micclass").value="WebTable"
web.add "html tag","TABLE"
Set coll=Browser("India Hotels| Star Hotels|").Page("India Hotels| Star Hotels|").ChildObjects(web)
cnt=coll.count
oShell.popup "Web Tables Count:    "&cnt,2,"Web Table Info"
For i=0 to cnt
rowcnt=coll(i).Rowcount
'oShell.popup "Row Count:     "&rowcnt,2,"Row Info"
  For rowno=1 to rowcnt
       colcnt=coll(i).columncount(rowno)
   ' oShell.popup "Column Count:     "&colcnt,2,"Col Info"
    For colno=1 to colcnt
celldata=coll(i).GetCellData(rowno,colno)
               If (celldata<>"") Then
'oShell.popup celldata,1,"Cell Info"
print celldata
End If
Next
  Next
Next
'Code for checking the DNS services by using oShell Object
Option Explicit
Dim fso,myfile,str,pos,oShell,res
Const ForReading=1
Set oShell=CreateObject("wscript.shell")
oShell.run "CMD /c net start > D:\myfile123.txt"
Set fso=CreateObject("Scripting.FilesystemObject")
Set myfile=fso.OpenTextfile("D:\myfile123.txt",ForReading,False)
While myfile.AtEndOfStream<>True
str=myfile.Readall
   pos=Instr (1,str,"DNS Client",VBTextCompare)
If (pos<>0) Then
 res=Mid(str,pos,10)
 msgbox res
 If (res="DNS Client") Then
 Msgbox "DNS Services Running   "&res
 Else
 Msgbox "DNS Services not Running"
 End If
End If
Wend
set oShell=nothing


browser("Google Accounts").Page("Google Accounts").Image("Visual verification").CaptureBitmap "D:\img.bmp" @@ hightlight id_;_3146758_;_script infofile_;_ZIP::ssf1.xml_;_
'Code for finding the Hyper Links in a webpage by using Child Objects
Option Explicit
Dim oLink,coll,cnt,i,link,oShell
Datatable.GlobalSheet.AddParameter "MyLinks",""
set oShell=CreateObject("wscript.shell")
Set oLink=Description.Create
'oLink("micclass").value="Link"
oLink("html tag").value="A"
Set coll=Browser("CreationTime:=0").Page("index:=0").ChildObjects(oLink)
cnt=coll.Count
'Msgbox "No of Hyper Links:    "&cnt
oShell.popup "No of Hyper Links:    "&cnt,2,"Links Info"
For i=0 to cnt-1
'Datatable.SetCurrentRow(i+1)
link=coll(i).GetROProperty("name")
If (link<>"") Then
oShell.popup link,1,"Links Info"
End If


If (link="blogs") Then
coll(i).click
Exit For
End If
Exit For
Datatable.Value("MyLinks","Global")=link
Print coll(i).GetROProperty("name")
Next


datatable.ExportSheet "D:\shruthi.xls","Global"
Set oLink=Nothing
'Code for closing the multiple Browsers
Option Explicit
Msgbox Browser("CreationTime:=0").Exist
While Browser("CreationTime:=0").Exist
Browser("CreationTime:=0").page("Index:=0").webedit("index:=0").Set "raghuqa"
wait 1
Browser("CreationTime:=0").page("Index:=0").webedit("index:=1").SetSecure "4a2b3fd87cbee9b873cbb15580f68489d5e426f73945c9806993"
wait 1
Browser("CreationTime:=0").page("Index:=0").webbutton("index:=0").Click
wait 1
Browser("CreationTime:=0").page("Index:=1").Link("index:=0").Click
wait 1
Browser("CreationTime:=0").Close
Wend
' code for closing multiple windows
Option explicit
Msgbox Dialog("index:=0","text:=Login").Exist
While  Dialog("index:=0","text:=Login").Exist
Dialog("index:=0","text:=Login").WinEdit("index:=0","attached text:=Agent Name:").Set "asdf"
wait 1
Dialog("index:=0","text:=Login").WinEdit("index:=1","attached text:=Password:").Set "mercury"
wait 1
Dialog("index:=0","text:=Login").WinButton("index:=0","text:=OK").Click
wait 1
window("text:=Flight Reservation").Close
Wend
'Code for creating the text file by using the FSO
Option Explicit
Dim fso,myFolder,myfile
Const Forwriting=2,ForAppending=8
Set fso=CreateObject("scripting.filesystemobject")
Set myFolder=fso.CreateFolder("D:\shruthi")
Set myfile=fso.Createtextfile("D:\shruthi\file123.txt",Forwriting,True)
'Set myfile=fso.OpenTextFile("D:\shruthi\file123.txt",ForAppending ,True)
myfile.writeline "My Name is Krish"
myfile.writeblanklines(1)
myfile.writeline "My Name is Raghu"
myfile.writeblanklines(1)
myfile.writeline "My Name is Srinivas"
myfile.close
Set fso=Nothing
Set myfile=Nothing
Set myFolder=Nothing


'Code for DataBase Connection first method with DSN
Option Explicit
Dim conn,recobj,recordcnt,fieldscnt,col,i,j
Datatable.AddSheet("Jampani")
Set conn=CreateObject("ADODB.Connection")
conn.open "DSN=QT_Flight32"
'conn.open "Server=jampani;Driver=Microsoft Access Driver (*.mdb);DBQ=C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight32.mdb;Trusted_Connection=yes"
'conn.open "Server=jampani;Driver=SQL Server;DataBase=Master;UserID=sa;Password=sa"
'conn.open "Server=jampani;Driver=OracleDriver;DataBase=Master;UserID=sa;Password=sa"


Msgbox "Connection Status:     "&conn.State
If (conn.state=1) Then
Reporter.ReportEvent micPass,"Checking the DataBase Connections","DB Connection success"
Else
Reporter.ReportEvent  micFail,"Checking the DataBase Connections","DB Connection failure"
End If
Set recobj=CreateObject("ADODB.Recordset")
recobj.open "Select * from Flights where Flight_Number<1110",conn,1
recordcnt=recobj.recordcount
msgbox "Record Count:   "&recordcnt
fieldscnt=recobj.fields.count
Msgbox "Fields count:    "&fieldscnt
For each col in recobj.fields
Datatable.GetSheet("Jampani").Addparameter col.Name,""
Next
For i=0  to recordcnt-1
Datatable.SetCurrentRow(i+1)
    For j=0 to fieldscnt-1
          Datatable.Value(j+1,"Jampani")=recobj(j)
Next
recobj.movenext
Next
'Datatable.ExportSheet "c:\bharathi.xls","Jampani"
recobj.save "D:\bharathi.xml",1
recobj.save "D:\bharathi.txt",1
conn.close
Set conn=nothing
Set recobj=nothing


'Code for designing the HTML doc By using the FSO
Option Explicit
Dim fso,myfile
Const Forwriting=2
Set fso=CreateObject("Scripting.FilesystemObject")
Set myfile=fso.CreateTextFile("D:\file1234.html",ForWriting,True)
myfile.writeline "<html>"
myfile.writeline "<head>"
myfile.writeline "<title>TestCase Results</title>"
myfile.writeline "</head>"
myfile.writeline "<body bgcolor=green>"
myfile.writeline "<center>"
myfile.writeline "<h1>Test Case Results</h1>"
myfile.writeline "<br><br><br><br>"
myfile.writeline "<table bgcolor=red border=2 align=center>"
myfile.writeline "<tr><th>Sno</th><th>TestCase</th><th>Exp.Results</th><th>Act.Results</th><th>StartTime</th><th>Status</th></tr>"
myfile.writeline "<tr><td>1</td><td>Login</td><td>Login should be open</td><td>Login should be success</td><td>"&Now&"</td><td>Pass</td></tr>"
myfile.writeline "<tr><td>2</td><td>Inser Order</td><td>Inser Order should be open</td><td>Inser Order should be success</td><td>"&Now&"</td><td>Pass</td></tr>"
myfile.writeline "<tr><td>3</td><td>Update Order</td><td>Update Order should be open</td><td>Update Order should be success</td><td>"&Now&"</td><td>Fail</td></tr>"
myfile.writeline "</table>"
myfile.writeline "</body>"
myfile.writeline "</center>"
myfile.writeline "</html>"
myfile.close
Set fso=nothing
Set myfile=nothing
'Code for external environment variables
Option Explicit
Dim path1,ph1
path1=Environment.ExternalFileName


Msgbox IsEmpty(path1)
If (path1=Empty) Then
Environment.LoadFromFile "C:\Documents and Settings\Administrator\Desktop\shruthi\Envfile.xml"
Msgbox "UserID:   "&Environment.Value("UserID")
Msgbox "Password:   "&Environment.Value("Password")
Msgbox "Job:   "&Environment.Value("Job")
Msgbox "Sal:   "&Environment.Value("Sal")
Msgbox "Location:   "&Environment.Value("Location")
Else
Msgbox "File Already in use:   "&path1
End If
Code for external actions
RunAction "Login [Code for actions]", oneIteration
'Code for getting the drives info by using FSO
Option Explicit
Dim fso,oDrive,driv,strout
Set fso=CreateObject("scripting.filesystemobject")
Set oDrive=fso.Drives
For each driv in oDrive
strout=strout&"Available Drives:    "&driv.DriveLetter&VBCrlf
strout=strout&"IS Ready:    "&driv.IsReady&VBCrlf
strout=strout&"Drive Type:    "&driv.DriveType&VBCrlf
strout=strout&"VolumeName:    "&driv.VolumeName&VBCrlf
strout=strout&"Drive Path:    "&driv.Path&VBCrlf
strout=strout&"RootFolder:    "&driv.RootFolder&VBCrlf
strout=strout&"SerialNumber:    "&driv.SerialNumber&VBCrlf
strout=strout&"FileSystem:    "&driv.FileSystem&VBCrlf
strout=strout&"Free space:    "&driv.Freespace&VBCrlf
strout=strout&"FileSystem:    "&driv.TotalSize&VBCrlf
Next
Msgbox strout


'Code for launching the Browser
Option Explicit
Dim ie,url
Public Function Launch_Browser(url)
  Set ie=CreateObject("InternetExplorer.Application")
  ie.visible=true
  ie.ToolBar=1
  ie.Navigate url
  Set ie=Nothing
End Function


Call Launch_Browser("www.google.com")
Call Launch_Browser("www.rediffmail.com")
'+++++++++++++++++++++++++++++++++++++++++++++++++
Public Function Launch_App(arg1)
  Set wsh=CreateObject("wscript.shell")
  wsh.run arg1
  Set wsh=nothing
End Function


Call Launch_App("Notepad.exe")
wait 1
Call Launch_App("cmd.exe")
wait 1
Call Launch_App("www.google.com")
wait 1
Call Launch_App("EXCEL.EXE")
wait 1
Call Launch_App("calc.exe")
wait 1
Call Launch_App("www.msn.com")


'+++++++++++++++++++++++++++++++++++++++++++++++++++++
InvokeApplication "notepad.exe"
wait 1
InvokeApplication "cmd.exe"
wait 1
InvokeApplication "EXCEL.EXE"
wait 1
InvokeApplication "WINWORD.EXE"
wait 1
InvokeApplication "calc.exe"
wait 1
InvokeApplication "C:\Program Files\Internet Explorer\IEXPLORE.EXE"
Systemutil.Run "Notepad.exe"
wait 1
Systemutil.Run "www.bharathmatrimony.com"
wait 1
Systemutil.Run "C:\Documents and Settings\Administrator\Desktop\Scripts"
wait 1
systemutil.Run "C:\Documents and Settings\Administrator\Desktop\Day-5th.xls"


'Code for reading text from text file by using FSO
Option Explicit
Dim fso,myfile,str
Const Forreading=1
Set fso=CreateObject("scripting.filesystemobject")
Set myfile=fso.OpenTextfile("D:\Anup.txt",ForReading,false)
While myfile.Atendofline<>true
str=myfile.readline
msgbox str
Wend
myfile.close
Set fso=nothing
Set myfile=nothing
'Code for reading the XML file by using XMLUtil.CreateObject
Option Explicit
Dim doc,root,child,childitem,subchild,subitem,cnt,cnt1,i,j
Set doc=XMLUtil.CreateXML
doc.LoadFile "C:\Documents and Settings\Administrator\Desktop\env123.xml"
Msgbox doc
Set root=doc.GetRootElement
'Msgbox "Root Element Name:   "&root.ElementName
'Msgbox "Root Element Value:   "&root.Value
Set child=root.Childelements
cnt=child.count
'msgbox "Child Count:   "&cnt
For i=1 to cnt
Set childitem=child.item(i)
'Msgbox "Child Item Name:   "&childitem.ElementName
'Msgbox "Child Item Value:   "&childitem.Value
Set subchild=childitem.childElements
cnt1=subchild.count
'Msgbox "Subchild Count:    "&cnt1
   For j=1 to cnt1   
  Set subitem=subchild.Item(j)
  Msgbox "Sub child Item:   "&subitem.ElementName
  Msgbox "Sub child Item:   "&subitem.Value
Next
Next
Set doc=Nothing
Set child=nothing
Set childitem=nothing
Set subchild=nothing
Set subitem=nothing
'Code for registry keys -FSO,oShell,Dictionary objects
Option Explicit
Dim  oShell
set oShell=CreateObject("wscript.shell")
oShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\fso\ProgID","scripting.filesystemobject","REG_SZ"
oShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\wsh\ProgID","wscript.shell","REG_SZ"
oShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\dict\ProgID","scripting.dictionary","REG_SZ"
Msgbox oShell.RegRead ("HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\fso\ProgID")
Msgbox oShell.RegRead ("HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\wsh\ProgID")
Msgbox oShell.RegRead ("HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\dict\ProgID")
oShell.RegDelete "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\fso\ProgID"
oShell.RegDelete "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\wsh\ProgID"
oShell.RegDelete "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\dict\ProgID"
oShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\ie\ProgID","InternetExplorer.Application","REG_SZ"
Set oShell=Nothing


'Code for Built-In Enviroment Variables to read system info
Msgbox "Computer Name:    "&Environment.Value("LocalHostName")
Msgbox "Operating System:    "&Environment.Value("OS")
Msgbox "OS Version:    "&Environment.Value("OSVersion")
Msgbox "Action Name:    "&Environment.Value("ActionName")
Msgbox "Action Iteration:    "&Environment.Value("ActionIteration")
Msgbox "TestName:    "&Environment.Value("TestName")
Msgbox "Test Iteration:    "&Environment.Value("TestIteration")
Msgbox "ProductName:    "&Environment.Value("ProductName")
Msgbox "Product Version:    "&Environment.Value("ProductVer")
Msgbox "Product Dir:    "&Environment.Value("ProductDir")
Msgbox "Test Dir:    "&Environment.Value("TestDir")


***************************************************


'Code for finding the Broken links by using child objects
Option Explicit
Dim brlnk,desc,cnt,i,coll,oShell,link
Set oShell=CreateObject("wscript.shell")
Set desc=Description.Create
desc("html tag").Value="A"
Set coll=Browser("Yatra.com My Bookings").Page("Yatra.com My Bookings").ChildObjects(desc)
cnt=coll.count
oShell.popup "No of Links:   "&cnt,2,"Links Info"
For i=0 to cnt-1
Set coll=Browser("Yatra.com My Bookings").Page("Yatra.com My Bookings").ChildObjects(desc)
'link=coll(i).GetRoProperty("name")
oShell.popup coll(i).GetRopRoperty("name"),1,"Link Info"
coll(i).click
If (coll(i).GetRoProperty("title")="Cannot find server") Then
brlnk=brlnk+1
End If
Browser("Yatra.com My Bookings").Back
Next
Msgbox "No of Broken Links:   "&brlnk
Set oShell=nothing


*****************************************************
'Code for external environment variables
Option Explicit
Dim path1,ph1
path1=Environment.ExternalFileName


Msgbox IsEmpty(path1)
If (path1=Empty) Then
Environment.LoadFromFile "C:\Documents and Settings\Administrator\Desktop\shruthi\Envfile.xml"
Msgbox "UserID:   "&Environment.Value("UserID")
Msgbox "Password:   "&Environment.Value("Password")
Msgbox "Job:   "&Environment.Value("Job")
Msgbox "Sal:   "&Environment.Value("Sal")
Msgbox "Location:   "&Environment.Value("Location")
Else
Msgbox "File Already in use:   "&path1
End If


*******************
'To log off
set a=createobject("wscript.shell")
spth="%windir%\SYSTEM32\rundll32.exe user32.dll,LockWorkStation"
a.run spth,0,false


****************************************


to Shut down


set a=createobject("wscript.shell")
a.sendkeys "%{F4}"
a.sendkeys "{TAB}"
a.sendkeys "~"


********************************


'Code for registry keys -FSO,oShell,Dictionary objects
Option Explicit
Dim  oShell
set oShell=CreateObject("wscript.shell")
oShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\fso\ProgID","scripting.filesystemobject","REG_SZ"
oShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\wsh\ProgID","wscript.shell","REG_SZ"
oShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\dict\ProgID","scripting.dictionary","REG_SZ"
Msgbox oShell.RegRead ("HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\fso\ProgID")
Msgbox oShell.RegRead ("HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\wsh\ProgID")
Msgbox oShell.RegRead ("HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\dict\ProgID")
oShell.RegDelete "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\fso\ProgID"
oShell.RegDelete "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\wsh\ProgID"
oShell.RegDelete "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\dict\ProgID"
oShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\ie\ProgID","InternetExplorer.Application","REG_SZ"
Set oShell=Nothing


recovery
Function RecoveryFunction1(Object)
Object.close
Dialog("Login").WinEdit("Agent Name:").set "raghu"
Dialog("Login").WinButton("OK").click
Window("text:=Flight Reservation").close
End Function


'Code for recovery scenarios to handle runtime errors
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").WinEdit("Agent Name:").Set "Ram"
wait 1
Dialog("Login").WinEdit("Agent Name:").Type  micTab
Dialog("Login").WinEdit("Password:").SetSecure "4a444d321297d3fcbf6501e84b81d89dd5019247"
wait 1
Dialog("Login").WinEdit("Password:").Type  micTab
Dialog("Login").WinButton("OK").Type  micReturn
window("text:=Flight Reservation").Close
Dialog("Login").WinEdit("Agent Name:").Set "raghu"
wait 1
Dialog("Login").WinButton("OK").Click
window("text:=Flight Reservation").Close


'Code for getting vowel,consonent and special char count
Option Explicit
Dim str1,char,cnt,vcnt,ccnt,splcnt,spacecnt,i
vcnt=0
ccnt=0
splcnt=0
spacecnt=0
str1=LCase(InputBox("Enter Any Text:   "))
Msgbox str1
cnt=Len(str1)
For i=1 to cnt
char=Mid(str1,i,1)
If (char="a" or  char="e" or char="i" or char="o" or char="u" )Then
vcnt=vcnt+1
ElseIf(char="@" or char="#" or char="$" or char="&" or char="*" or char=":" or char="," or char="|" )Then
splcnt=splcnt+1
 Elseif(char=" ") Then
    spacecnt=spacecnt+1
 Else
  ccnt=ccnt+1
End If
Next
Msgbox "Vowel Count:     "&vcnt
Msgbox "Consonent Count:     "&ccnt
Msgbox "Special charactor:     "&splcnt
Msgbox "space Count:     "&spacecnt

1 comment: