Micro Focus QTP (UFT) Forums
exception has been thrown by the target of invocation - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: exception has been thrown by the target of invocation (/Thread-exception-has-been-thrown-by-the-target-of-invocation)



exception has been thrown by the target of invocation - trupti10 - 03-04-2008

i keep getting this error and there is no reason that i can mention for it to occur because sometimes it comes up and sometimes it doeesnt. and it comes for the following line :
Code:
SwfWindow("AiCMS Case Management").SwfWindow("Manage Case").SwfToolbar("_ManageCase_Toolbars_Dock_Area").ClickToolbarTool "tbMain","SAVERECEIPT"

Pls help


RE: exception has been thrown by the target of invocation - Ankur - 03-11-2008

make sure to open QTP first then AUT...

Also are you running the application from Eclipse?


RE: exception has been thrown by the target of invocation - trupti10 - 03-12-2008

no i m not running the application from Eclipse.

In fact now we have moved on to Infragistics 7.3 CLR 2.0 and all seems ok to me with the config files and the sample scripts in Testadvantage also executed as well

But my application after checking all of this still gives the following error though it records correctly.

Code:
Object doesn't support this property or method: 'SwfWindow(...).SwfWindow(...).SwfEdit(...).set'

for the following line
Code:
SwfWindow("AiCMS Case Management").SwfWindow("Search").SwfEdit("txtLastOrg").Set "a"


This is the script file :

Code:
Dim objConnection
Dim objRecordset
set objconnection = createobject("ADODB.Connection")
Set objRecordset = createobject("ADODB.recordset")
strquery = "SELECT top 1 CASE_NUMBER AS 'Case Number',LAST_NAME ,  FIRST_NAME , MIDDLE_NAME , TOTAL_BAL_AMT AS 'Balance Due' FROM [Arizona_Test].[dbo].PARTYSEARCH group by case_number,LAST_NAME , FIRST_NAME ,MIDDLE_NAME,TOTAL_BAL_AMT having count(case_number) = 1 and TOTAL_BAL_AMT  >50"
Set objrecordset = generateDB(objconnection,objrecordset,strquery)
SwfWindow("AiCMS Case Management").SwfToolbar("_Main_Toolbars_Dock_Area_Top_2").SelectRibbonTab "Accounting"
SwfWindow("AiCMS Case Management").SwfToolbar("_Main_Toolbars_Dock_Area_Top_2").ClickRibbonTool "Accounting:Receipting","Payment Receipting"
SwfWindow("AiCMS Case Management").SwfWindow("Search").SwfEdit("txtLastOrg").SetFocus
SwfWindow("AiCMS Case Management").SwfWindow("Search").SwfEdit("txtLastOrg").SetCaretPos 0

SwfWindow("AiCMS Case Management").SwfWindow("Search").SwfEdit("txtLastOrg").Set "a"

SwfWindow("AiCMS Case Management").SwfWindow("Search").SwfToolbar("_Main_Toolbars_Dock_Area_Top").ClickToolbarTool "tbrSearch","Search"
SwfWindow("AiCMS Case Management").SwfTab("SwfTab").CloseTab "Search"

This is the function library for generateDB function

Code:
Public Function generateDB(byref objConnection,byref objRecordset, strQuery)
If objconnection.state  = 0 then
    objConnection.Open Environment.value("DSN") 'Comes from a global variable
end if
    Const adOpenStatic = 3
    Const adLockOptimistic = 3
    Const adUseClient = 3
    
    Set objRecordset = CreateObject("ADODB.Recordset")
                objRecordset.CursorLocation = adUseClient
    objRecordset.CursorType = adopenstatic
    objRecordset.LockType = adlockoptimistic
    
    objRecordset.Source = strQuery
    objRecordset.ActiveConnection = objConnection
    
      objRecordset.Open 'Executes the Query
                set  generateDB=objRecordset
                
End Function


Sometimes it gives me a "General Run Error" at the beginning itself. Sometimes it gives the "exception has been thrown by the target of invocation" error. It acts weird is all that i can say.
So now how can we resolve this?


RE: exception has been thrown by the target of invocation - Ankur - 03-12-2008

See if .type method works .

If it works you can use, Type "a" instead of Set "a"