How to export a list of test scripts form a test plan folder?
Question ID: 108369

How to export a list of test scripts form a test plan folder?
I have an end user looking to export a list of testscripts from a test plan folder. Is it possible? If so what are the steps?

Marked as spam
Posted by (Questions: 89, Answers: 0)
Asked on May 1, 2018 6:28 pm
Answers (1)
Private answer

You will have to use the OTA API to accomplish this. What I did was to create a button on the Test Plan ToolBar and then write the code in the ActionCanExecute function in the workflow. To use this you click on the folder that has the test scripts that you want and then click the icon on the toolbar. This will only get the test scripts in that folder, not any child folders. You will also need to be in Tree View. Below is a working example of what I did.

To download test scripts...

The first step is to create a button in the Test Plan Module Customize --> Workflow --> Script Editor --> Toolbar Button Editor

- select Test Plan in the Command bar drop-down
- click the Add button
- enter a Hint if needed and Select an icon image
- click Apply

Next create global variable under the Customize --> Workflow --> Script Editor --> Common script

this should be at the top of the script outside a any sub procedures or functions

*** Dim myFolderID ***

Now go to Customize --> Workflow --> Script Editor --> Test Plan Module Script --> TestFolder_MoveTo

Within the Sub TestFolder_MoveTo enter the following to assign the current folder ID to myFolderID

*** myFolderID = TestFolder_Fields.Field(''AL_ITEM_ID'').Value ***

Finally, add the following under Customize --> Workflow --> Script Editor --> Common script --> ActionCanExecute(ActionName)

If ActionName = ''TestPlan_Action1'' Then

Ans = msgbox(''Are you sure you want to download test scripts for'' & VbCrLf & ''Folder ID: '' & myFolderID, vbYesNo + vbExclamation + vbDefaultButton2, ''Warning'')
If Ans = vbYes then
Dim TestFact 'Services for managing test
Dim myTestFilter 'The TDFilter object for the factory
Dim myTestList 'List of objects according to specified filter (empty in this example)
Dim thisTest 'The current test in my test list
Dim thisTestStorage 'Holds the extended storage object for this test
Dim thisTestDownloadLocation 'Holds the user specified location to download the scripts to
Dim thisTestDownloadPath 'Holds the return value of the test's ExtendedStorage load method (the path files downlaoded to)
set tdc = TDConnection
set TestFact = tdc.TestFactory 'create the test factory
set myTestFilter = TestFact.Filter 'create the TDFilter (not used here)
set myTestList = TestFact.NewList('''') 'creates a new list of all tests (could use the TDFilter to limit returns if needed)
For Each thisTest in myTestList 'loop through all tests
If thisTest.FolderID = myFolderID then 'select test where folder ID matches the selected folder
If Not(thisTest.type = ''MANUAL'') then 'select test that do not have MANUAL test
'msgbox thisTest.Name & VbCrLf & thisTest.Type & VbCrLf & thisTest.FullPath
Set thisTestStorage = thisTest.ExtendedStorage 'create an ExtendedStorage object the test
thisTestDownloadLocation = InputBox(''Enter the path to download scripts to... '', ''Path'') 'prompt user for download location
'msgbox ''You have entered:'' & VbCrLf & thisTestDownloadLocation
thisTestStorage.ClientPath = thisTestDownloadLocation & thisTest.Name & ''TestStorage'' 'sets the download path for ExtendedStorage object
'msgbox ''The final path to the files will be... '' & VbCrLf & thisTestStorage.ClientPath
thisTestDownloadPath = thisTestStorage.Load(''*.*'', TRUE) 'actually download the test script files saves output (path to download location)
msgbox ''This is what was returned from the Load method'' & VbCrLf & ''You should see the final path below'' & VbCrLf & thisTestDownloadPath 'shows download path location


Marked as spam
Posted by (Questions: 0, Answers: 309)
Answered on May 1, 2018 6:35 pm
I think I can work with this
( at May 1, 2018 6:36 pm)

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

Scroll to Top