Close Opened Browsers Except QC
Dim intIndex
Set oDesc=Description.Create
oDesc(“micclass”).Value=”Browser”
intIndex=0
While Browser(“micclass:=Browser”,”index:=”&intIndex).exist(0) and intIndex<Desktop.ChildObjects(oDesc).count
If instr(1, Browser("micclass:=Browser","index:="&intIndex).getRoProperty("name"),"Quality Center") = 0 Then
SystemUtil.CloseProcessByHwnd( Browser("micclass:=Browser","index:="&intIndex).getRoProperty("hwnd"))
else
intIndex=intIndex+1
End if
wend
Advertisement
4 Comments »
Leave a Reply
-
Archives
- July 2011 (1)
- March 2011 (1)
- November 2010 (1)
- November 2008 (4)
- October 2008 (2)
- September 2008 (2)
- June 2008 (1)
- March 2008 (4)
- February 2008 (44)
-
Categories
- Automated Test Script Creation Process
- Automating MS Word
- Automating QC
- Automation Object Model For QTP
- Backward compatability in QTP
- Browser Scripts
- COM and QTP
- compare 2 text files
- Descriptive programming
- Descriptive Programming and Child Objetcs
- Dictonary Object
- DotNetFactory
- Excel Automation
- Extra Topics
- Files and Folders
- General Standards to be followed in Test scripts
- New Features In QTP9.5
- QC-OTA
- QTP Additional Faqs
- QTP Faqs
- QTP Naming Convention
- QTP Tips and Faqs
- Running stored procedures from QTP
- Send keyboard keys
- Uncategorized
- Uninstall a software using QTP
- Uninstall a software using vbscript
- Update data in a database
- VBScript and IE Automation
- VBScript Faqs and Useful resources
- What’s New in Quick Test Pro 9.0
- Whats New in QTP 9.5
- XML Scripting
-
RSS
Entries RSS
Comments RSS

I have used code given below to identify all the child object of type ‘Links’
in a perticuler web Page but
In Line 3 i am getting genral error can you please let me know what is the solution for this error.
Set desc=description.Create
desc(“micClass”).Value=”Links”
Set obj_link=Browser(“Creationtime:=0″).Page(“Title:=.*”).ChildObjects(desc)
msgbox obj_link.count
Whereas if i m runnung this script on my friends tool it works fine.I m not able to understand whats wrong in my tool.Please tell me the solution.
hi
can you please explain the following code?
Function CaptureToWord()
sTscenarioPath = GetData(“ScreenshotPath”)&Environment(“TestName”)
sWordFileName= sTscenarioPath&”\”&Environment(“TestName”)&”.doc”
Dim sFileCapture()
sFileCaptureLen = -1
Const END_OF_DOC = 6
Set fileSys = CreateObject(“Scripting.FileSystemObject”)
Set sSubFiles=fileSys.GetFolder(sTscenarioPath).Files
If sSubFiles.Count = 0 Then
Set fileSys = Nothing
Set sSubFiles = Nothing
Exit Function
End If
Dim aResponsibility()
Datatable.AddSheet(Environment(“TestName”))
Datatable.ImportSheet GetData(“FilePath”),Environment(“TestName”),Environment(“TestName”)
iRowCount =datatable.GetSheet(Environment(“TestName”)).GetRowCount
k = 0
For iCountNo = 1 to iRowCount
Datatable.GetSheet(Environment(“TestName”)).SetCurrentRow(iCountNo)
If trim(Datatable(“Testcase_Id”,Environment(“TestName”))) “” Then
ReDim Preserve aResponsibility(k)
ReDim Preserve aTCName(k)
aResponsibility(k) = Trim(Datatable(“Responsibility”,Environment(“TestName”)))
aTCName(k) = Trim(Datatable(“TestCase_Name”,Environment(“TestName”)))
k = k+1
End If
Datatable.GetSheet(Environment(“TestName”)).SetCurrentRow(iCountNo)
If trim(Datatable(“Testcase_Id”,Environment(“TestName”))) = “” Then
Exit For
End If
Next
Set obj_MSWord = CreateObject(“Word.Application”)
Set objDoc = obj_MSWord.Documents.Add()
For Each iSubFiles in sSubFiles
If Right(iSubFiles.Name,4) = “.png” Or Right(iSubFiles.Name,4) = “.PNG” Then
ReDim Preserve sFileCapture (sFileCaptureLen+1)
sFileCapture(UBound(sFileCapture)) = iSubFiles & fileSys.GetFile(iSubFiles).DateLastModified
sFileCaptureLen = sFileCaptureLen +1
End If
Next
For i = LBound(sFileCapture) To UBound(sFileCapture)-1
min = i
For j = (i + 1) to UBound(sFileCapture)
if StrComp(Right(sFileCapture(j),20), Right(sFileCapture(min),20))=-1 Then
min = j
End If
Next
Temp = sFileCapture(i)
sFileCapture(i) = sFileCapture(min)
sFileCapture(min) = Temp
Next
For i = LBound(sFileCapture) To UBound(sFileCapture)
strLWordFile = Split(sFileCapture(i),”\”)
strDesc = Split(strLWordFile(4),”.png”)
sLWordFile = strLWordFile(0) &”\” & strLWordFile(1) & “\” & strLWordFile(2) & “\” & strLWordFile(3) & “\” & strDesc(0) & “.png”
‘MsgBox strDesc(0)
TC = Split(strDesc(0),”_TC”)
iTC = GetNumberFromString(TC(1),0)
tChar = Len(TC(1))
iChar = Len(iTC)
sActivity = Right(TC(1),tChar-iChar)
eActivity = Replace(sActivity,”_”,” “)
Set objSelection = obj_MSWord.Selection
‘objSelection.TypeText “Table”&i
objSelection.TypeParagraph()
Set objRange = objSelection.Range
objDoc.Tables.Add objRange, 5, 2
Set objTable = objDoc.Tables(i)
objTable.Range.Font.Size = 15
objTable.Range.Style = “Table Contemporary”
objTable.Cell(1, 1).Range.Text = “Scenario Id”
objTable.Cell(2, 1).Range.Text = “Responsibility”
objTable.Cell(3, 1).Range.Text = “Test Case Id”
objTable.Cell(4, 1).Range.Text = “Test Case Name”
objTable.Cell(5, 1).Range.Text = “Screen/Activity/Verification”
objTable.Cell(1, 2).Range.Text = Environment(“TestName”)
objTable.Cell(2, 2).Range.Text = aResponsibility(iTC-1)
objTable.Cell(3, 2).Range.Text = “TC”&iTC
objTable.Cell(4, 2).Range.Text = aTCName(iTC-1)
objTable.Cell(5, 2).Range.Text = eActivity
objSelection.EndKey END_OF_DOC
objSelection.TypeText ” ”
Set objTable = Nothing
Set objRange = Nothing
Set objSelection = Nothing
‘obj_MSWord.Selection.TypeText strDesc(0) &” ”
obj_MSWord.Application.Selection.InlineShapes.AddPicture(sLWordFile)
obj_MSWord.Selection.InsertBreak(1)
Next
obj_MSWord.ActiveDocument.SaveAs(sWordFileName)
obj_MSWord.ActiveDocument.Close()
obj_MSWord.Quit
Set obj_MSWord = Nothing
Set objDoc = Nothing
Set sSubFiles = Nothing
Set fileSys = Nothing
End Function
Hi Mohan,
I am trying to open QC in QTP. I am able to do that. I can open a File-Open dialog box using DotNetFactory.CreateInstance as you suggested. However I am not able to open the Quality Center path in that dialog box. Will you help?
Function getcharcount(strchar,strsearch)
Dim i
For i=1 to len(strsearch)
If mid(strsearch,i,1)=strchar Then
getcharcount=getcharcount+1
End If
Next
msgbox getcharcount
msgbox strchar
End Function please give me qtp code to automate this
pl