I need to pass an object and its work into a function, so that every time I can only call this function and save me to record the same steps for all objects, such as checking the object before performing the operation. Similar to user registration function in QTP / UFT.
However, Testcomplete does not have this feature (at least, as far as I know, I would be glad to know if there is any)
This is my code that I am trying but cannot:
Call OpenPageorTab("Aliases.Admin.wndMain.toolStrip", ".Visible") Function OpenPageorTab(obj, method) 'if obj.Exists then execute a = obj&method delay(1000) OpenPageorTab = True 'Else log.Error "Unable to find the object" OpenPageorTab = False 'End if
using the if condition when I used to pass an object instead of a string
It does not work when executing the execute statement and gives me a VbScript runtime error while this statement is executing. my question is double -
- How to pass objects and their work into functions and execute it
- It is also possible to pass the object it self instead of the string for ex:
obtoolbar = "Aliases.Admin.wndMain.toolStrip"
Call OpenPageorTab(obtoolbar, ".Visible")
Appreciate any help or direction on this subject
EDIT 1
Iβm somewhere close to the answer, but not for sure. I can pass the object as a string - Check the code below
Call OpenPageorTab("Aliases.Admin.wndMain.toolStrip", ".Click") Function OpenPageorTab(obj, method) ' if obj.Exists then eobj = "" & obj & method execute (eobj) delay(1000) OpenPageorTab = True ' Else log.Error "Unable to find the object" OpenPageorTab = False ' End if End Function
However, I still need to pass the object something like
Set oToolStrip = Aliases.Admin.wndMain.toolStrip Call OpenPageorTab(oToolStrip, ".Click")
This is what I cannot do.
EDIT 2 I already received an answer to this problem and posted a solution. As the saying goes, is there a way that a function can be used as a method?