Custom Search

Monday, June 4, 2012

Loading Actions, Libraries, Repository and Environment files at run time (built-in Functions) without creating QTP object

Actions:
LoadAndRunAction(TestPath, ActionName, [Iteration], [Parameters])

Environment File:
Environment.LoadFromFile("C:\QuickTest\Files\MyVariables.xml")

Repositories:
RepositoriesCollection.Add(RepPath)

RepPath = file://mercury/SORS/MySharedObjectRepository.tsr

Library Files:
ExecuteFile “FilePath”

New feature in QTP11v: LoadFunctionLibrary "FilePath"

PilePath=”c:\Add.vbs”

Friday, June 1, 2012

How to load External Environment veriables at run time in QTP

Dim App ‘As Application
‘ Launch QTP
Set App = CreateObject(“QuickTest.Application”)
App.Launch
App.Visible = True
‘ Load an INI file with user-defined parameters
App.Test.Environment.LoadFromFile “C:\Test_Params\environment_file1.ini”
‘ Set the value of a specific user-defined Environment variable
App.Test.Environment.Value(“newvariable”) = “new value”
As you can see from the example, the Environment variable file is actually an .ini file. The structure would be:
[Environment]
var1=value1
var2=value2



Enable and Disable of Error Handling at runtime in QTP

On Error Resume Next:

On Error Resume Next statement enables the Error handling in the code.If there is error in the code "On error Resume Next" ignores it and continue with next line of code.

On Error Go to 0:
On error got to 0 statement disables error handling we have previiously enabled it by using On Error resume Next.



Monday, May 28, 2012

How to change characters horizontal to vertical in one string using vb script


str=inputbox("Enter String","")
dim strArray()
For i = 1 to len(str)
   ReDim preserve strArray(i)
   strArray(i)=mid(str,i,1)
Next
For i = 1 to len(str)
   strmsg=strmsg& strArray(i) & vbNewLine
                     OR
   'strmsg=strmsg& strArray(i) & vbcrlf
Next
msgbox strmsg

Wednesday, May 23, 2012

How many types of actions in qtp

Reusable action: An action that can be called multiple times by the test with which it is stored (the local test), as well as by other tests.

Non-reusable action: An action that can be called only in the test with which it is stored, and can be called only once.

External action: A reusable action stored with another test. External actions are read-only in the calling test, but you can choose to use a local, editable copy of the Data Table information for the external action.

How to get Caps and small charecters count or seperate caps and small in one string

str= "KAMESwararao"
For i=1 to len(str)
a=mid(str,i,1)
If ASC(a)>=65 AND ASC(a)<=90 Then
strRes=strRes &a
else
strRes2=strRes2 &a
End If
Next
CapLen=len(strRes)
SmallLen=Len(strRes2)
msgbox "Your Result is- Caps : " &strRes &" - Small : "& strRes2
msgbox "Len of Caps : " & CapLen & "- Len of Small : " & SmallLen

OTherWay:
Dim myarray(),caps,small
mystring = "sAnKeTh"
For i=1 to len(mystring)
ReDim myarray(i)
myarray(i-1) =mid(mystring,i,1)
If myarray(i-1) = Ucase(myarray(i-1)) Then
caps = caps&myarray(i-1)
else
small = small&myarray(i-1)
End If
Next
msgbox caps
msgbox small

Friday, May 18, 2012

Creating Random string with required no of charecters

 Call GenerateRandomString(9)
Function GenerateRandomString(StrLen)
        Dim myStr
        Const MainStr= "abcdefghijklmnopqrstuvwxyz"
        For i = 1 to StrLen
          myStr=myStr & Mid(MainStr,RandomNumber(1, Len(MainStr)),1)
        Next
        GenerateRandomString = myStr
    End Function