I am working on updating the test results in test lab of ALM 12.01 version from soapui pro.so i am doing this through groovy scripting. I can now filter the test case and make it passed or failed,but could not do the same for test steps.have used step factory to get the count of nodes. but i have no idea of using run factory for updating each field in test step like 'status','actual results'.below is the part of code i m stuck with.
// Create a new Test Run
newRun= tsfact.RunFactory.AddItem('Run_Auto')
newRun.Status = 'Passed'
newRun.Post()
newRun.CopyDesignSteps()
newRun.Post()
// Populate Auto Run Test step Data
tsSteps = newRun.StepFactory.NewList("")
log.info tsSteps.count()
for(tsStep in tsSteps)
{
tsStep.Status = 'Passed'
}
My script is from the opposite side but i think it should work.
I run soapui test from ALM 11.
There is my vb script to populate ALM teststeps from soap ui teststep.
For each step, i call this function, juste replace my stepFactory currentRun by your variable newRun
Sub addRunData(CurrentRun, sStepName, sStatus, sDescription, sExpected, sActual )
Dim objRun
Set objRun = CurrentRun
//Create Step object and add values to Object array
Set objStep = objRun.StepFactory.AddItem(null)
objStep.Field("ST_STEP_NAME")= sStepName
objStep.Field("ST_STATUS") = sStatus
objStep.Field("ST_DESCRIPTION") = sDescription
objStep.Field("ST_EXPECTED") = sExpected
objStep.Field("ST_ACTUAL") = sActual
objStep.Post
Set objStep = Nothing
end sub
You can insert expected and actual value with assertions or messages from your request for example
Related
I am using code to get values of HTML attributes like:
Set myPhoto = doc.DocumentElement.getElementsByTagName("ul"): i = 2
For Each e In myPhoto
...
MyNodeValue = Trim(e.ChildNodes(0).ChildNodes(0).ChildNodes(0).src)
...
next
It has been working well until now. Excel shows me "Automation error" in case nodespath is exist.
The code string work well if use Children(0) vs Childnodes(0) like:
MyNodeValue = Trim(e.Children(0).Children(0).Children(0).src)
I can't understand what happened with code and why ChildNodes(0) doesn't work?
In my Test Plan I have two folders. One with all my active test cases and one with all my archived test cases. I need to replace a lot of 'Affected Module' from one value to another, however - I don't want the folder with archived to be affected by this.
So, is there a way of doing search and replace only on a specific folder (and all the sub-folders) in HP ALM?
As far as I know the search and replace function in grid view replaces all instances of the value so I can't use that directly.
Here is a simple OTA code that updates the field ts_user_04 for all the test case in folder Subject\Automated and its sub-folder from whatever value to Quoting.
Please, change the column name as per your requirement. You can easily find the DB column for any field in HP ALM by going to the Management tab if you have access to it. Even otherwise you can get all the mapping by using OTA. (I hope you have the necessary access)
Inorder to run the OTA code, you need to install ALM Connectivity add-in which you can get it from the tools section in your ALM home page
Public TDconnection
Public reqPath
Public testPath
'Call the main Function
updateAllTests
Public Function login()
Dim almURL, almUserName, almPassword, domain, project
almURL = "https://.saas.hp.com/qcbin/"
almUserName = ""
almPassword = ""
domain = ""
project = ""
testPath = "Subject\Automated" ' Change it as per your folder structure
Set TDconnection = CreateObject("tdapiole80.tdconnection")
TDconnection.ReleaseConnection
TDconnection.InitConnectionEx almURL
TDconnection.login almUserName, almPassword
TDconnection.Connect domain, project
End Function
Public Function updateAllTests()
login
Set TreeMgr = TDconnection.TreeManager
Set TestTree = TreeMgr.NodeByPath(testPath)
If Err.Number = 0 Then
Set comm = TDconnection.Command
comm.CommandText = "update test set ts_user_04='Quoting' where ts_test_id in (select ts_test_id from test, all_lists where ts_subject in (select al_item_id from all_lists where al_absolute_path like (select al_absolute_path from all_lists where al_item_id=" & TestTree.NodeID & ") || '%' ) and ts_subject = al_item_id)"
comm.Execute
End If
logout
MsgBox "Flag Update successful", vbInformation
End Function
Public Function logout()
TDconnection.Disconnect
TDconnection.logout
TDconnection.ReleaseConnection
Set TDconnection = Nothing
End Function
I am trying to execute the test cases in QC ALM through an Excel macro. I am able to access the tests in testlist, but I am not able to find the particular test case I need to execute by its ID.
Below is the sample code I am using:
Set tsTreeMgr = tdConnection.testsettreemanager
Set tsFolder = tsTreeMgr.NodeByPath(nPath)
' --Search for the test set passed as an argument to the example code
Set tsList = tsFolder.FindTestSets("Test Set Name")
'------Accessing the Test Cases inside the Test SEt ----
Set theTestSet = tsList.Item(1)
For Each testsetfound In tsList
Set tsFolder = testsetfound.TestSetFolder
Set tsTestFactory = testsetfound.tsTestFactory
Set tsTestList = tsTestFactory.NewList("")
For Each tsTest In tsTestList
MsgBox (tsTest.Name+","+ tsTest.ID)
testrunname = "Test Case name from excel sheet"
'----Accesssing the Run Factory ---
Set RunFactory = tsTest.RunFactory
Set obj_theRun = RunFactory.AddItem(CStr(testrunname))
obj_theRun.Status = "Passed"
obj_theRun.Post
Next
Next
Any help to get TestCase in testset of testlab to execute would be great help.
I think you are looking for the TestId property of the TSTest object. So in your loop you could just test whether TestId matches the value from Excel:
If tsTest.TestId = testidfromexcel Then
' do something
End If
Or you can use a Filter to only get the TSTest instances from your Test Set that matches the respective test ID from Excel:
Set testSetFilter = tsTestFactory.Filter
testSetFilter.Filter("TC_TEST_ID") = testidfromexcel
Set tsTestList = testSetFilter.NewList()
Now your tsTestList should only contain test instances from the test with the ID from Excel.
im trying use for loop on this to loop from datasheet, but its only reading one row, dont know where i did wrong any Ideas?
import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.usermodel.DataFormatter
cellDataFormatter = new DataFormatter()
//Create formula evaluator
fEval = new XSSFFormulaEvaluator(context.srcWkSheet.getWorkbook())
//Increment the rowcounter then read in the next row of items
RC = context.rowCounter;
if(RC<=context.srcWkSheet.getLastRowNum()){//Check if we've reached the last row
for(int i =0; i < RC; i++)
{
curTC = testRunner.testCase
sourceRow = context.srcWkSheet.getRow(i)//Get a spreadsheet row
//Step through cells in the row and populate property data
data1Cell = sourceRow.getCell(0)
curTC.setPropertyValue("data1",cellDataFormatter.formatCellValue(data1Cell ,fEval))
data2Cell = sourceRow.getCell(1)
curTC.setPropertyValue("data2",cellDataFormatter.formatCellValue(data2Cell ,fEval))
data3Cell = sourceRow.getCell(2)
curTC.setPropertyValue("data3",cellDataFormatter.formatCellValue(data3Cell ,fEval))
//Rename test cases for readability in the TestSuite log
curTC.getTestStepAt(0).setName("data1-" + curTC.getPropertyValue("BC"))
//Go back to first test request with newly copied properties
testRunner.gotoStep(0)
}
}
From the API documentation for testRunner.gotoStep(0):
Transfers execution of this TestRunner to the TestStep with the specified index in the TestCase
Execution will continue after the indexed step. You are probably expecting it will return back to your loop, which is incorrect!
You probably meant something like: curTC.getTestStepAt(0).run(context.testRunner, context); API documentation.
You could also have an issue with the excel file you are providing. XSSFFormulaEvaluator I believe is only for old style *.xls excel format. Could be an issue if you're feeding *.xlsx format excel file.
In SoapUI NG Pro there's a DataSource test step that simply allows you to point to a file (xls or xlsx) and feed in the data
http://www.soapui.org/data-driven-tests/functional-tests.html
I am trying to run a testcomplete project and the script routines within it.
i used the following code:
Dim pn As String, un As String, rn As String
'Set ProjectSuiteName = "C:\Users\s.amin\Documents\TestComplete 10 Projects\DigiStyle1\DigiStyle1.pjs"
pn = "DigiStyle_App"
un = "login_test1"
rn = "loginApp"
' Creates the application object
Set TestCompleteApp = CreateObject("TestComplete.TestCompleteApplication")
' Obtains the integration object
Set IntegrationObject = TestCompleteApp.Integration
' Opens the project suite
IntegrationObject.OpenProjectSuite ("C:\Users\s.amin\Documents\TestComplete 10 Projects\DigiStyle1\DigiStyle1.pjs")
' Runs the routine
IntegrationObject.RunRoutine(pn, un, rn)
But i am getting the syntax error in the last statement. used this code from smartbear site itself.
When you call a procedure with parameters, you need to either use the Call keyword:
Call IntegrationObject.RunRoutine(pn, un, rn)
or drop the parentheses:
IntegrationObject.RunRoutine pn, un, rn