Custom Search

Friday, March 30, 2012

How to reverse the string with out using strreverse function and not rotate the loop up to string length? ex: if you have a string length 10 characters, string should be reversed in off of the loop rotation.

 str=inputbox ("Enter String:")
 intlen=round(len(str)/2)
 leftstr=mid(str,1,intlen)
 rgtstr=mid(str,intlen+1,len(str))
 res=mid(str,intlen,1)
 For i=1 to len(leftstr) -1

  leftres=mid(rgtstr,i,1)
  rgtres=mid(leftstr,intlen-i,1)
  res=leftres&res&rgtres

 Next

 If Len(str)<>len(res) Then
  res=mid(str,len(str),1)&res
 End If
 msgbox res

Wednesday, March 7, 2012

Can we set value in Edit /Text field without using .set method.

Using below code you can enter values in edit field with out using set method
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Object.value="gmail"

Monday, March 5, 2012

How do we add object repository dynamically in QTP

Rem declaring Variables
Dim qtApp 'QuickTest.Application object variable
Dim qtRepositories 'QuickTest.Repositories object variable
' Create the QTP Application object
Set qtApp = CreateObject("QuickTest.Application")
' Create the Repositories object
Set qtRepositories = qtApp.Test.Actions("DriverScript").ObjectRepositories
' If there are any Repository , remove them
qtRepositories.RemoveAll()
' Add Repository
qtRepositories.Add(strRepositoryFilePath)
' Release the Application object
Set qtApp = Nothing
' Release the Repositories object
Set qtRepositories = Nothing
==========OR========
Use below code- below code is supported after QTP 9.5 versions.
RepositoriesCollection.Add "C:\Test.tsr"


Friday, March 2, 2012

Sorting an array with out using Sort method in vbscript/QTP

dim arrSortOut(8)
arrSortOut(0)="xCount"
arrSortOut(1)="zExec"
arrSortOut(2)="yFinance"
arrSortOut(3)="HR"
arrSortOut(4)="IT "
arrSortOut(5)="!aaaLegal"
arrSortOut(6)="Liberman"
arrSortOut(7)="Martha"
arrSortOut(8)="Regis"

for i = UBound(arrSortOut) - 1 To 0 Step -1
     for j= 0 to i
          if arrSortOut(j)>arrSortOut(j+1) then
             temp=arrSortOut(j+1)
             arrSortOut(j+1)=arrSortOut(j)
             arrSortOut(j)=temp
         end if
    next
next

for x=0 to 8
    print arrSortOut(x)
next

Sorting an array using Sort method in Vbscript/QTP

dim myArray(6)
myArray(0)= "New"
myArray(1)= "Old"
myArray(2)= "Add"
myArray(3)= "Create"
myArray(4)= "Insert"
myArray(5)= "Delete"

Set myArrayList= CreateObject( "System.Collections.ArrayList" )
For i=0 to Ubound(myArray)-1
myArrayList.Add myArray(i)
Next

Rem Sorting array list
myArrayList.sort

For i=0 to Ubound(myArray)-1
print myArrayList.item(i)
Next