Highlighted
New Member.
1840 views

How to call a UFT internal VBS function from an external application?

I have two parallel test platforms. One using HPE UFT the other using NI LabWindowsCVI.

I need to initiate an operation in UFT from LabWindowsCVI.

I have a VBS Function implemented and unit tested in UFT to perform my desired action.

What I need to know is how to invoke this function from a process external to UFT.

Most of the online information deals with calling something external to UFT. That is not my question.

I have UFT up and running, now from and external process I need to call a VBS function that is defined internally to UFT.

Please describe the method and if possible provide a small example.

Do not focus on LabWindowsCVI. From there I have many options. The question is generic.

"How to call a UFT internal VBS function from an external application?"

 

Gratitude for all ideas and potential solutions. 

Tags (2)
0 Likes
4 Replies
Highlighted
Trusted Contributor.
Trusted Contributor.

Hello UFT stores the test script in the test folder, 

Hae in mind that UFT has one script for action, so you can find the test script in the action folder,

by default test are stoe inthe documents folder, for example the script can be found in

C:\Users\<User>\Documents\Unified Functional Testing\LicenseRealeseTest\Action1\Script.mts

I havent test this, but my first guess would be that this would not work because you will require the UFT runtime engine to run the test successfully and i dont think that this will load the runtime engine, 

I also would not recomend to ems with this folder because you ight mess with the script or the Object repositoy, 

Mt recomendation would be to create a external VBS file to run the Quick test profesional and open and run the test rom there like so..

Dim qtApp
Dim qtTest

'Create the QTP Application object
Set qtApp = CreateObject("QuickTest.Application")

'If QTP is notopen then open it
If qtApp.launched <> True then

qtApp.Launch

End If

'Make the QuickTest application visible
qtApp.Visible = True

'Set QuickTest run options
'Instruct QuickTest to perform next step when error occurs

qtApp.Options.Run.ImageCaptureForTestResults = "OnError"
qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = False

'Open the test in read-only mode
qtApp.Open "C:\Users\madriart\Documents\Unified Functional Testing\LicenseRealeseTest", True

'set run settings for the test
Set qtTest = qtApp.Test

'Instruct QuickTest to perform next step when error occurs
qtApp.Test.Settings.Run.OnError = "NextStep"

'Run the test
qtApp.Test.Run

'Check the results of the test run
MsgBox qtApp.Test.LastRunResults.Status

' Close the test
qtApp.Test.Close

'Close QTP
qtApp.quit

'Release Object
Set qtTest = Nothing
Set qtApp = Nothing

'End of the script

 

There is a lot of ays to make this run more complex or more simple, you could easily access this script from any external aplication (maybe Windows task Scheduler) and your test will run and save result in UFT

I hope this answer your questions,

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

createobject("quicktest.application")  in your C like language with http://www.ni.com/white-paper/4438/en/

But then its really the question what you want to call or what your goal is.

Just running a test should not be that hard

but if you want to call certain functions that ared defined in function libraries I doubt if you will get anywhere.. My suggestion would then be to host the windows scripting host or if you want to recognize objects to not use HP UFT but IUIAutomation from Microsoft directly.. Within HP UFT you can use dotnetfactory maybe with that you can bridge the 2 tools but that will be some work.

0 Likes
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

I would recommend you investigate Test Batch Runner, which is available in UFT->Tools. It is an interface designed to create a stand alone file, that can be called and run from any interface, and calls and runs the configured UFT tests. It can be called from windows scheduler for example, so it should be possible to call from your tool.

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

maybe also check this example

https://community.microfocus.com/t5/Unified-Functional-Testing/C-compile-on-the-fly-thru-dotnetfactory/td-p/1597172

With a C# class/module you can make a listener in HP UFT and dotnetfactory.createinstance

From the other app you can then start UFT (thru createobjecte quicktest.application) and run the test that starts the C# class module that can do callbacks to the specialized VBS functions of UFT.

communicate with the listener and have an HP UFT VBScript module doing the details what you want.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.