Custom Search

Monday, October 22, 2012

How to Import\Download attachment files from QC Test Plan to local Drive


LocalFilePath = "C:\Updated_Files_Form_QC_TillDate"
Set QCConnection = QCUtil.QCConnection
Set treeManager = QCConnection.TreeManager
'Specify the Quality Center path to the desired folder
QC_Path ="Subject\Automation\Regression\Library"
Set node = treeManager.nodebypath(QC_Path)
set stratt = node.attachments
For Each obj_QCAttachment In stratt.NewList("")
      Set obj_QCAttachmentStorage = obj_QCAttachment.AttachmentStorage
      obj_QCAttachmentStorage.ClientPath = LocalFilePath 'give the directory where u want to save the file
      obj_QCAttachmentStorage.Load obj_QCAttachment.Name,True
Next

Wednesday, October 3, 2012

How to find length of the string without using Len function

str="FindLength"
'Here you need to add one single character which is not existed in your string
str=FindLengthr"
'here i had added one character "r" in the last of the string
msgbox instr(1,str,"r",1)-1

OtherWay:
str="VBSCRIPTING"
i=1
do
str1=mid(str,i,1)
if str1<>"" then
i=i+1
else
exit do
end if
loop until str1=""
msgbox i-1

How to verify some text in Excel which is having large number of data

Set xl=CreateObject("Excel.Application")
xl.Workbooks.Open "C:\Test.xlsx"
Set r = xl.Range("A1:N20").Find("kamesh")
If r Is Nothing Then
xl.Cells(1,1).Value= "not found"
Else
xl.Cells(1,1).Value= "found"
End If
xl.quit
set xl=nothing

Friday, August 10, 2012

Getting Newest file from folder

spath ="C:\eLink\Log"
str=GetNewestFile(spath)
Function GetNewestFile(spath)
sNewestFile = Null ' init value
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(sPath)
Set oFiles = oFolder.Files
' enumerate the files in the folder, finding the newest file
For Each oFile In oFiles
On Error Resume Next
If IsNull(sNewestFile) Then
sNewestFile = oFile.Path
dPrevDate = oFile.DateLastModified
Elseif dPrevDate < oFile.DateLastModified Then
sNewestFile = oFile.Path
dPrevDate = oFile.DateLastModified
End If
On Error Goto 0
Next
If IsNull(sNewestFile) Then sNewestFile = ""
GetNewestFile=sNewestFile
End Function

Between QTP 9.5 & earlier versions

1. Checkpoints and Output values can be seen & edited in the OR while same was not possible in the earlier versions of QTP.
2. Installation file is a single one bundled with all add-ins, previously we have to download add-ins separately.
3. Movie recorder was introduced in the results
4. Web add-in extensibility add- in was introduced
5. Maintenance run mode was introduced
6. It also supports the 64 bit windows edition while the earlier were supporting only 32 bit systems only
7. Bitmap tolerance feature was introduced in QTP 9.5

Monday, July 2, 2012

Write a code to get last Friday date.

'Gets the last friday's date


strCurrentSysDate = Date
strModDate = dateadd("ww",-1,strCurrentSysDate)
numWeekDay = 6- weekday(strModDate)
strModifiedDate = dateadd("d",numWeekDay,strModDate)
strmonth =left(monthname(month(strModifiedDate)),3)
If len(cstr(day(strModifiedDate))) < 2 Then
strDate = "0"&day(strModifiedDate)
else
strDate = day(strModifiedDate)
End If
strYear = year(strModifiedDate)
strPrevDate = strmonth& "/" & strDate & "/" & strYear
Msgbox strPrevDate

Friday, June 29, 2012

How to get highest value from given values


Dim num, i, Length1
num=array(100,34,12,98,43,89,49,56)
Length1 = UBound(num) 'Find the length of array
For i= 1 to Length1
   If (num(i)>num(0)) Then
     num(0)=num(i)
   End If
Next
MsgBox num(0)