I have integrated Jenkins and QTP 10.0. I am able to run my test scripts from Jenkins. Only issue I am facing is that QTP output result is not displaying on Jenkins console. Below is the VB script I wrote :
Dim App,strDrive, strfoldername,objFSO, objFolder, strPath, TestScriptpath1, oFSO
' Launch QuickTest Professional and make it visible.
Set App = CreateObject("QuickTest.Application")
Set qtResultsObj = CreateObject("QuickTest.RunResultsOptions")
Set fsobj=CreateObject("Scripting.FileSystemObject")
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.WorkBooks.Open("C:\Batch File\QTP_Scripts.xls")
Set xlSheet = xlBook.WorkSheets("Sheet1")
'Set stdout = fsobj.GetStandardStream (1)
'stdout.WriteLine "This will go to standard output."
Set WshShell = CreateObject("WScript.Shell")
App.Launch
App.Visible = True
strfoldername="_Result"
'Read all the Test path from the Excel and Loop through all the tests.
For ix = 2 To xlSheet.UsedRange.Rows.Count
TestScriptpath = xlSheet.Cells(ix, 1).value
TestScriptpath1=Split(TestScriptpath, "\")
'Open the test in QuickTest Professional.
App.Open TestScriptpath,True,False
'Create Environment Variables to pass the results from QTP to runner.vbs
APP.Test.Environment.Value("JenkinsFlag") = "Y"
APP.Test.Environment.Value("JenkinsTestCaseDescription") = TestScriptpath1(2)
sResultFolderPath="C:\BUILD_TAG\"
'' Get the test object.
Set qtTest = App.Test
ResultFolderPath1=sResultFolderPath&TestScriptpath1(2)&strfoldername
Set objFolder = fsobj.CreateFolder(sResultFolderPath1)
'Execute the test. Instruct QuickTest Professional to wait for the test to finish executing.
'This statement specifies a test results location.
qtResultsObj.ResultsLocation=sResultFolderPath1
qtTest.Run qtResultsObj, True
StrResult=qtTest.LastRunResults.Status
xlSheet.Cells(ix, 2).value=StrResult
'Write the result in the console
While APP.Test.isRunning
If APP.Test.Environment.Value("JenkinsFlag") = "Y" Then
'APP.Test.Environment.Value("JenkinsFlag") = "N"
' Show TC ID and Description
WshShell.StdOut.WriteLine APP.Test.Environment.Value("JenkinsTestCaseDescription")&TestScriptpath1(2)
'stdout.WriteLine APP.Test.Environment.Value("JenkinsTestCaseDescription") &TestScriptpath1(2)
'Wait till the test is executed & result is updated
While (APP.Test.Environment.Value("JenkinsTestCaseResult") = Reporter.runstatus AND APP.Test.isRunning)
WshShell.Sleep 1000
'stdout.Sleep 1000
Wend
'Show the Result
WshShell.StdOut.Write APP.Test.Environment.Value("JenkinsTestCaseResult")
'stdout.Write APP.Test.Environment.Value("Jenkins TestCaseResult")
End If
WshShell.Sleep 1000
'stdout.Sleep 1000
Wend
' Close the test.
qtTest.Close
Next
xlApp.ActiveWorkbook.Save
xlApp.ActiveWorkbook.Close
App.Quit
xlApp.Quit
If Not xlApp Is Nothing Then
xlApp.Quit
Set xlApp = Nothing
End If
'Release the created objects.
set qtResultsObj = nothing
set fsobj= nothing
set qtTest = nothing
set App = nothing
set xlApp = nothing
set xlBook = nothing
set xlSheet= nothing
I had created a sample runner file which will execute the test, show the results in the console & create a simple HTML file.
Check this for more info:
http://www.testautomationguru.com/qtpuft-jenkins-github-svn-integration/
Source code:
https://github.com/vinsguru/tag-qtp-jenkins-demo
Related
Maximo 7.6.1.1:
I want to run a Maximo automation script by invoking a URL in a separate system.
Is it possible to do this?
This is a great use-case and something that we've been working through in the last few days.
Create automation script. - mine is called automation_api_test
Manually invoke it through the API using a browser to make sure that you can actually get it to run. (%servername%/maximo/oslc/script/automation_api_test?var1=1212321232&var2=1555&site=OPS&_lid=wilson&_lpwd=wilson)
Script it like you would your regular automation script. Here's one that can read in a few parameters from the URL and use those to perform operations in the core system.
importPackage(Packages.psdi.server);
importPackage(Packages.psdi.util.logging);
var resp = {};
// Get the Site ID from the Query Parameters
//var site = request.getQueryParam("site");
var var1 = request.getQueryParam("var1");
var var2 = request.getQueryParam("var2");
var site = request.getQueryParam("site");
//var zxqponum = request.getQueryParam("ponum");
//logger.debug(zxqprinter);
service.log("TESTING script Params" + request.getQueryParams());
service.log("var1 " + request.getQueryParam("var1"));
service.log("var2 " + request.getQueryParam("var2"));
//count the number of WO's in the site
var woset = MXServer.getMXServer().getMboSet("WORKORDER", request.getUserInfo());
woset.setQbe("SITEID","="+site);
var woCount = woset.count();
resp.wo_count = woCount;
woset.close();
// Get Total Count
resp.total = woCount;
//create the response - still not sure why I had to append the vars to a string.
resp.var1= "" + var1;
resp.var2= "" + var2;
resp.site= "" + site;
var responseBody = JSON.stringify(resp);
Here's an expanded version of Kasey's answer.
Create a sample automation script in Maximo:
Automation Scripts >> More Actions >> Create >> Script
Script [name]: HELLOWORLD
Script Language: js
Paste in this code:
//THIS IS JAVASCRIPT! NOT JYTHON!
//load("nashorn:mozilla_compat.js"); //More info about this here: https://stackoverflow.com/questions/57537142/maximo-js-automation-script-importpackage-is-not-defined
//importPackage(Packages.psdi.server);
//importPackage(Packages.psdi.util.logging);
var resp = {};
var var1 = request.getQueryParam("var1");
resp.var1= " " + var1 + " World!";
var responseBody = JSON.stringify(resp);
Click Create
Try out a URL:
This URL will send the word "Hello" to the automation script. The automation script will append the word " World!" onto "Hello".
The phrase, "Hello World!" is returned.
In a browser, run this URL: http://yourhostname:1234/maximo/oslc/script/helloworld?var1=Hello&_lid=wilson&_lpwd=wilson
Replace yourhostname with your host name
Replace 1234 with your port number
Replace maximo with the appropriate value.
The URL request should return this JSON object to the browser:
{"var1":" Hello World!"}
From there, create a hyperlink in a separate system (using the above URL). And click it to run the automation script.
If the last line in the script were to be deleted, nothing would be returned to the browser.
Note:
The URL only seems to work for me under the WILSON user. It doesn't work with my own user:
{"oslc:Error":{"oslc:statusCode":"401","spi:reasonCode":"BMXAA7901E","oslc:message":
"You cannot log in at this time. Contact the system administrator.","oslc:extendedError"
:{"oslc:moreInfo":{"rdf:resource":"http:\/\/something\/maximo\/oslc\
/error\/messages\/BMXAA7901E"}}}}
Best guess is: my user is not set up correctly.
Here's a really simple JavaScript example:
responseBody = "asdf";
Then just run the URL in a browser (or somewhere else like an automation script in Maximo or a Python script in GIS).
https://<<my host>>/maximo/oslc/script/testscript
It's pretty much the same for Python (no semi-colon):
responseBody = "asdf"
I'm having a problem where I can do every single function in a command line version of lua however, when I run the program it won't throw any errors it just ends.I'm not sure how to diagnose this but I have tried getting an error to be thrown a couple times for different things and it will error and print the error.
power = peripheral.wrap("bottom")
mon = peripheral.wrap("top")
x,y = mon.getSize()
clearTerm = function()
term.clear()
term.setCursorPos(1,1)
end
clearBoth = function()
clearMon()
clearTerm()
end
intLen = function(bar)
tab = tostring(bar)
tab = string.len(tab)
return tab
end
checkPower = function()
total = power.getMaxEnergyStored()
local til = intLen(total)
local yy = math.floor(y/2)
local tol = math.floor(x-til)
mon.setCursorPos(yy+0,tol/2)
for z=1,til do mon.write("-") end
mon.setCursorPos(yy-1,tol/2)
mon.write(total)
while true do
current = power.getEnergyStored()
local cil = intLen(current)
local col = math.floor(x-cil)
mon.setCursorPos(yy+1,col/2)
mon.write(current)
sleep(1)
end
end
I'll leave a link to the pastebin of the full program here too.
First of all, you can add some outputs to your code. Just add stuff like
print "1" -- debug output
...
print "2" -- debug output
...
-- don't forget to remove these after you're done debugging!
to your code and see how many of them you see when running the program, this way you can narrow down when exactly the program crashes.
Also, I cannot find where the function clearMon() is defined, might that be source the problem, or is it defined elsewhere?
when using this very short script on the lua console on BizHawk (it's an emulator), Both the LUA console and BizHawk crashes at the same time.
I'd like to know if the error comes from my script or from BizHawk, her's the script: (What it is supposed to do is check if the player is not moving for a certain time period [TimeoutConstant] and if he is [cause he's dead, stuck or afk] the script loads a saved state called Filename and it starts again. Here's the script:
Filename = "yolo.state"
TimeoutConstant = 80
rightmost = 0
timeout = TimeoutConstant
function initializeRun()
savestate.load(Filename)
rightmost = 0
timeout = TimeoutConstant
end
function getPositions()
marioX = memory.read_s16_le(0x94)
marioY = memory.read_s16_le(0x96)
local layer1x = memory.read_s16_le(0x1A);
local layer1y = memory.read_s16_le(0x1C);
screenX = marioX-layer1x
screenY = marioY-layer1y
end
initializeRun()
while true do
getPositions()
if marioX > rightmost then
rightmost = marioX
timeout = TimeoutConstant
end
if timeout <= 0 then
initializeRun()
end
timeout = timeout - 1
end
I assume by "crash" you mean "freeze" which is not at all the same thing. It's freezing because your script is putting the emulator into a busy loop. You didn't do anything to advance time in the emulator. The final two lines of your script need to be:
emu.frameadvance();
end
BTW, with emulator lua scripts, the name of the game being scripted is essential information.
In my SCVMM server, the following error is logged in events.
Event filter with query "SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE TargetInstance ISA "Win32_Processor" AND TargetInstance.LoadPercentage > 99" could not be reactivated in namespace "//./root/CIMV2" because of error 0x80041003. Events cannot be delivered through this filter until the problem is corrected.
How to resolve it?
Try this workaround from Microsoft. It's actually a good one, and comes with a "real" explanation of the problem.
http://support.microsoft.com/kb/2545227 (For Win7 and Server 2008 R2)
http://support.microsoft.com/kb/950375 (For Vista and Server 2008)
In summary, this is a leftover WMI registration from the ISO creation process that can be safely removed.
For Windows 7, make a .vbs file with the following and execute it from an elevated command prompt:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\subscription")
Set obj1 = objWMIService.ExecQuery("select * from __eventfilter where name='BVTFilter' and query='SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE TargetInstance ISA ""Win32_Processor"" AND TargetInstance.LoadPercentage > 99'")
For Each obj1elem in obj1
set obj2set = obj1elem.Associators_("__FilterToConsumerBinding")
set obj3set = obj1elem.References_("__FilterToConsumerBinding")
For each obj2 in obj2set
WScript.echo "Deleting the object"
WScript.echo obj2.GetObjectText_
obj2.Delete_
next
For each obj3 in obj3set
WScript.echo "Deleting the object"
WScript.echo obj3.GetObjectText_
obj3.Delete_
next
WScript.echo "Deleting the object"
WScript.echo obj1elem.GetObjectText_
obj1elem.Delete_
Next
I have made a new report using Crystal Reports 8.5 (report1) which uses a stored procedure as its data source. The stored procedure has 2 input parameters (#p1 and #p2) and when I enter some test data for #p1 and #p2 within crystal report IDE , every thing is all right. Then, I added the report1 in visual basic 6.0 IDE and added a new form (form1) and a crystal report viewer control on form1. Now please help me: I wanna to show the report1. What codes exactly should I write to show it?How send data user has entered to the stored procedure parameters via application?
I also get this error messsage: the server has not been opened yet"
What's wrong?
Specifying a report
Assumes that SampleReport has been added to your .Net project:
Dim parameter1 As CrystalDecisions.Shared.ParameterField
Dim parameter2 As CrystalDecisions.Shared.ParameterField
With SampleReport
.SetDatabaseLogon("user", "password", "server", "database")
'locate first parameter in report
parameter1 = .ParameterFields.Find("#p1", "")
'locate second parameter in report
parameter2 = .ParameterFields.Find("#p2", "")
End With
'create a new discrete-parameter value
Dim stringValue As New CrystalDecisions.Shared.ParameterDiscreteValue()
stringValue.Value = "USA"
'assign it to the parameter's current values collection
parameter1.CurrentValues.Add(stringValue)
'create a new discrete-parameter value
Dim numberValue As New CrystalDecisions.Shared.ParameterDiscreteValue()
numberValue.Value = 100
'assign it to the parameter's current values collection
parameter2.CurrentValues.Add(numberValue)
With Me.CrystalReportViewer1
.ReportSource = SampleReport
End With
write the below code in vb6
With rptControl
.ReportFileName = "MyCrystalReport1.rpt"
.WindowAllowDrillDown = True
.WindowMaxButton = True
.ParameterFields(0) = "#p1;"& p1Value & ";true"
.ParameterFields(1) = "#p2;"& p2Value & ";true"
.Connect = MyDatabaseConnectionString;
.Action = 1
End With