Wednesday, August 1, 2007

How to call Class inside 1 more Class and use it in Automation script

Class 1

On Error Resume Next
ExecuteFile "C:\Arun\testing.class"
if Err.Number <> 0 then
Reporter.ReportEvent micFail,"AccountAllocation.class", Err.Description
end if
Err.Clear

Class Main

private objTesting

private sub Class_Initialize()
objTesting=null
End Sub

public function getTestingReference
Set objTesting = New Testing
set getTestingReference= objTesting
end function

'Set objTesting = New Testing

'Call objTesting.add1


End Class


Class 2
Class Testing

Private a

Private Sub Class_Initialize()
a=null
end Sub

Public function Add1()
msgbox "inside"
End function

End Class

Script



'On Error Resume Next
ExecuteFile "C:\Arun\main.class"
if Err.Number <> 0 then
Reporter.ReportEvent micFail,"AccountAllocation.class", Err.Description
end if
Err.Clear


'private objTesting

' set getTestingReference = objTesting

Set objMain = New Main

'Call objTesting.add1
Set objTesting=objMain.getTestingReference


objTesting.add1

Problems with QTP

Problems with QTP

1)
QTP has some issues in identifying object in Descriptive programming..

mainly for "Class Name" we should use micclass
like wise some more properties are available

2)

While debugging QTP scripts from QC, some time QTP will get hangged.., it is a known issue and even mercury knows about it.
it happends even in 9.1 also

3)Check points...
Checkpoints are hidden inside OR file and we dont have option of exporting / importing from 1 place to other.. if we change approach it will land in problem

4)
Problem in identifying objects in case of very think client. some time identifying objects will be problem .. specialy for list objects..in Java env

5)
QTP doesn't support drag and drop objects on web

6)

QTP doen't record any objects from pdf file

7)

QTP result generation is not user friendly

spell check

Function CheckSpellErrors(Var)
Set obj = CreateObject("Word.Application")
obj.WordBasic.FileNew
obj.WordBasic.Insert Var
Set SpellErrCollection = obj.ActiveDocument.SpellingErrors
For each element in SpellErrCollection
CreateObject("wscript.shell").popup element,1,"Spell Error"
Next
NoofErrors = obj.ActiveDocument.SpellingErrors.Count
obj.Documents.Close (False)
obj.Quit
Set SpellErrCollection = Nothing
Set obj = Nothing
CheckSpellErrors = NoofErrors
End Function

Msgbox "Spell Error Count = "&CheckSpellErrors("Checki spelling Usingg Automated Testingz")