How to execute UFT scripts through AOM Framework? - hp-uft

I have Five Automated Script and want to execute overnight. Can anyone let me know how to execute it ?

Yes, you can schedule those tasks using task scheduler using Application Object Model(AOM).
There are many ways, one approach you can use am writing below:
Create a vbs file and trigger it using Windows scheduler. You can write code to pick up your execution scripts in UFT. Refer below code for your reference.
Set obj = CreateObject("Quicktest.Application")
'// Set AOM file and test script path
obj.Visible = True
obj.Launch
obj.Options.Run.ImageCaptureForTestResults = "OnError"
obj.Options.Run.RunMode = "Fast"
obj.Options.Run.ViewResults = False
obj.Open path '----"path of your script"
obj.Test.Run qtpResults,True
VarStatus =obj.Test.LastRunResults.Status
obj.Test.Close
Let me know if you need any other help. Happy to help :-)

Related

Controlling a servo at Raspberry Pi with Springboot and ServoBlaster

I am trying to control a servo motor from a web interface. I am using SpringBoot 2.0, ServoBlaster and pi4j.
In order to start the application I am running as root ./gradlew bootrun --no-daemon. It has to be root in order to handle the GPIOs and I don't have any security worries about the device.
In simplified (a class with just the main function) Java/Kotlin I achieved to control the servo by any of the following ways:
RPIServoBlasterProvider
val servoProvider = RPIServoBlasterProvider()
val servo0 = servoProvider.getServoDriver(servoProvider.definedServoPins[5])
println("Go to 150") //middle
servo0.servoPulseWidth = 150
println("Went to ${servo0.servoPulseWidth}")
Thread.sleep(1550)
Write to /dev/servoblaster
val out = PrintWriter(FileOutputStream("/dev/servoblaster"), true)
println("Go to 65 again")
out.println("5=65")
out.flush()
out.close
Call a secondary script which writes to /dev/servoblaster
val servoId = 5
val script = "/home/pi/ServoHardwareSteering.sh"
val cmdMinPosition = "$script $servoId 65"
val cmdMidPosition = "$script $servoId 150"
val cmdMaxPosition = "$script $servoId 235"
val runtime = Runtime.getRuntime()
println(cmdMidPosition)
runtime.exec(cmdMidPosition)//.waitFor()
Thread.sleep(1550)
Write the value to a file and have a secondary execute reading this file and applying this value to the servo
I have tried all of the above in Springboot but without success.
So the question is, could somebody tell me how could I:
use the RPIServoBlasterProvider class from Springboot? OR
write to /dev/servoblaster? OR
execute any terminal script? OR
where to save the script in order to be able to call it OR
write to a simple file (ex. afile.txt)? OR
solve the issue in a better way that I did not think about already.
Solutions at any of the above questions could help me solve my problem.
PS: Is there anything wrong with the blockquote for the source code in stackoverflow? I could not format it as a block and I used the line code formatting!
use the RPIServoBlasterProvider class from Springboot? OR
The same you did before - its Java (kotlin is based on) - or just use Kotlin with Spring https://spring.io/guides/tutorials/spring-boot-kotlin/
write to /dev/servoblaster? OR
The same like you did - everything is a file in linux, thus its writing to a ordinary file
execute any terminal script? OR
Runtime.getRuntime.exec - any variant or ProcessBuilder
where to save the script in order to be able to call it OR
Anywhere
write to a simple file (ex. afile.txt)? OR
point 2.
solve the issue in a better way that I did not think about already.
No experience with servo blaster.
The whole problem was with the servod of the ServoBlaster. It was accidentally killed and I had to run it once again!
I followed the No 5 solution.

How do we import the listener events of LibreOffice Writer in Visual Basic 6

How do we import the listener events of LibreOffice writer in Visual Basic 6?
I am trying to create a UNO service to get container listener event like following code,
Dim oListener As Object
oListener = CreateUnoListener("ContListener_",
"com.sun.star.container.XContainerListener")
I am getting an error
Compile error : Sub or Function not defined
Can anyone please help?
As explained here, CreateUnoListener does not work in VB6. So instead, it is necessary to implement the listener interface a different way.
Here is a VBScript example from https://wiki.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/Document_Events.
set xContext = objServiceManager.getPropertyValue( "DefaultContext" )
set xCoreReflection = xContext.getValueByName( "/singletons/com.sun.star.reflection.theCoreReflection" )
set xClass = xCoreReflection.forName( "com.sun.star.document.XEventBroadcaster" )
set xMethod = xClass.getMethod( "addEventListener" )
dim invokeargs(0)
invokeargs(0) = myListener
set value = objServiceManager.Bridge_GetValueObject()
call value.InitInOutParam("[]any", invokeargs)
call xMethod.invoke( objDocument, value )
Define a subroutine called myListener.
It may also help to check out the information at https://www.openoffice.org/udk/common/man/tutorial/office_automation.html.
There is a discussion of someone attempting similar code at https://forum.openoffice.org/en/forum/viewtopic.php?f=45&t=14217, although the final solution uses Javascript.
Disclaimer: I do not have any way to test VB6 code, so this information may not be entirely accurate. If you switch to Python or another language commonly used with LibreOffice then I can be of more help.

Need help for HP UFT -- Vb Script code

Firstly, I will give you some idea about what I am doing. I writing a few test cases without a framework, so for this I am creating a VBS file in which have written a code for launching of the UFT and opening of the action have created. Code is like this:
Set qtApp= CreateObject("QuickTest.Application")
qtApp.Launch
qtApp.Visible = True
Set qtTest = qtApp.Test
'And then call your scripts one after another
qtApp.Open "D:\UFT\TestScript\Function_Demo",true
Set qtTest = qtApp.Test
qtTest.Run
Also have created functions for each scenario which are associated with this Action, so whenever VBS file will be triggered by third system it will launch UFT and open the Action in which I am calling all the functions, so here comes my first question
How can I set the priority of the function so that it will run in sequence?
Also I wanted to write code for the result status as pass and fail and depending on the pass and fail status I wants to update the XML specific nodes with the status and also along with this wants to capture the screenshot of the test case whenever it's failed and for this also have to update the path in XML nodes.
As I am very new to the UFT so was not sure how to do this can someone please help me with this? How to write the code and what all things will be required?
Quick response will be appreciated.
Regarding Function Priority :-
Function in Test Action always takes priority over any other function with same name in any other function libs.
Second Priority is Function from Lib which is executed last[if u using loadfunctionlib or executefunctionlib]
Regarding XML specific nodes :-
Look for Res/Report/results.xml Summary Node
ex :- Summary sTime="*************" eTime="**************" passed="128" failed="2" warnings="36" /Summary
Question 2: UFT provides a function to update the results:
Reporter.ReportEvent micPass, "Step 1", "This step has passed. The object was found"
Reporter.ReportEvent micFail, "Step 1", "This step has failed. The object was not found"
it also provides a function to store the screenshot of the enire desktop
Desktop.CaptureBitmap "C:\Temp\HP-UFT-Test.png",true
Reporter.ReportEvent micFail, "Step", msg, "C:\Temp\HP-UFT-Test.png"
Its also possible to capture a screenshot of specific, objects for instance:
WpfWindow("SAP Work Manager").CaptureBitmap "C:\Temp\HP-UFT-Test.png",true
Reporter.ReportEvent micFail, "Step", msg, "C:\Temp\HP-UFT-Test.png"

HP UFT API Test - Saving Response/Checkpoint values

Is there a way to capture and store (or write to a file) the values returned in the Response? (Checkpoint values)
Using HP UFT 11.52
Thanks,
Lynn
I figured it out. In UFT API under Standard Activities, there are File function modules including "Write to File". I added the module to the test, set the path and other properties, passed the variable to the file and it worked! Couldn't be easier.
I mentioned this on my other answer , you can also write it programatically if you have dynamic array response please refer below:
https://stackoverflow.com/a/28012383/3972994
After running a test, in the test folder, you can find a Snapshots/LastIteration directory.
In it you can find the return value for each step saved in a txt file.
Pay attention that if you data drive the step, only the last iteration will be saved to file.
However, in the Test's log (Test dir/Log/vtd_user.log) you can find all the iterations persisted
Thanks,
Yossi
You do not need to use the standard activities if you do this
var iResponse = this.Activity.responsebody;
System.IO.File.WriteLines(#"directorypath&FileName);
the above will write the response to the file and rewrite it for every run

Conditional first run handler

I wonder if someone can help me with a simple script. I am not a good Titanium programmer yet, but I would like to be some day.
I need help with a script to check whether a certain settings file exists in the applicationDataDirectory.
I need a way to trigger this automatically in app.js:
If file with the with the name: "passWord.txt” does not(!) exist in applicationDataDirectory
then open window:
var w = Ti.UI.createWindow
I can´t find a event to check for this file and then open this window automatically. This will work as a “first run” event when the app is loaded the first time.
Try this
var file =Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,"passWord.txt”);
if ( file.exists() ) {
// do your work here.
}
For complete details Titanium.Filesystem.File.

Resources