Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
getting "type mismatch error" when calling function in qtp
#1
Solved: 10 Years, 8 Months, 4 Weeks ago
Hi
Iam very new to QTP and am trying to call a function from qtp.
my function is :

Code:
Function sample()
msgbox "sample function"
End Function

i have added this script to qtp ( file -> settings-> resources).
However when i calling the function(call sample())in qtp its giving "type mismatch error".
please help me.

I am using QTP 10 trail version with activex,vb and web addins.


Attached Files Image(s)
   
Reply
#2
Solved: 10 Years, 8 Months, 4 Weeks ago Wink 
Hi Nmakkena,

This error occurs only when QTP is not able to link call with definition. Its reasons may be:

1. Name mismatch (In call & definition)
2. Function is not associated properly (You can check this by ALT+G).

On the basis of error screenshot, I think you forgot to add parenthesis in the end of function calling.

Smile
Reply
#3
Solved: 10 Years, 8 Months, 4 Weeks ago
Hi,

Please See if Library file has been associated with the test correctly, you can confirm this by navigating to Resources >> Associated function libraries.
Code:
call sample
Call sample()
sample()
sample
All should work in your case.

Also let me know if you are using classes?

You can associate library file with test in following ways also:
[From QTP Help]
Associate an open function library with a test:[This is from QTP Help]
1. Make sure that the test with which you want to associate the function library is open in QuickTest.
2. Create or open a function library in QuickTest. (Before continuing to the next step, make sure that the function library you want to associate with the test is the active document—you can click the function library's tab to bring it into focus.)
3. Save the function library either in your Quality Center project or in the file system.
4 In QuickTest, select File > Associate Library '<Function Library>' with '<Test>', or right-click in the in the function library and select Associate Library '<Function Library>' with '<Test>'. QuickTest associates the function library with the open test.
OR
Associate a function library with a test using the Resources pane:
1. In the Resources pane, right-click the Associated Function Libraries node in the tree and select Associate Function Library. The Open Function Library dialog box opens.
2. In the sidebar, select the location of the file, for example, File System or Quality Center Test Resources. Browse to and select a function library, and click Open.
3. The function library is associated with the test and is displayed as a node under the Associated Function Libraries node in the tree.

Thanks,
Rajeshwar
Reply
#4
Solved: 10 Years, 8 Months, 4 Weeks ago Wink 
Hi Rajeshwar,

You are absolutely correct as we can call a method in different ways. Thanks for correcting my statement. Well your explanation was really good.

Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Different Type of Dropdown Selector zunebuggy 6 2,821 05-01-2018, 06:46 PM
Last Post: zunebuggy
  Calling a function in a Test Script from a function library anupam4j 3 5,890 06-26-2015, 12:31 AM
Last Post: babu123
  cannot use the type method on object and submit is not working jove1776 5 8,371 01-27-2015, 10:08 PM
Last Post: Parke
  How to import .xlsx file type to QTP qtped 3 6,304 03-27-2014, 01:33 PM
Last Post: Ankur
  type mismatch error in QTP QAlearningQTP 1 6,794 02-04-2014, 08:14 AM
Last Post: QAlearningQTP

Forum Jump:


Users browsing this thread: 1 Guest(s)