cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Projects and Keyword Test information from TestExcecute COM object

Highlighted
Community Expert

Getting Projects and Keyword Test information from TestExcecute COM object


Hi, I have finished writing a .Net library that wraps the TestExecute COM object to which I can feed an XML file to execute a list of Tests.


 


I am now writing a manager app for selecting Tests to include in, and generating, the XML file.


 


I would like to be able to do the following:


1. Open a Suite from the file path


2. Select a Project


3. Select Tests for the Project to include in the XML file, these could be:


   a) Script Routines


   b) Keyword Tests


   c) Project Test Items


 


I have worked out how to get Script Routines and Project Test Items but I cannot find a way of getting a list of Projects for the Suite or a way of getting Keyword Tests for a Project once the ItcProjectIntegration object is obtained.


 


Is it possible to get these items, and , if so, how?


 


Regards,


Phil Baird

5 REPLIES 5
Highlighted
Community Manager

RE: Getting Projects and Keyword Test information from TestExcecute COM object


Hi Phil,


 


As far as I can see, that's impossible to get the full collections of projects/tests, etc. via the Integration object.


You can get these objects only by names.


 

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Not applicable

RE: Getting Projects and Keyword Test information from TestExcecute COM object

Hi,



I did a similar project like you Phil, which works really good with Test Complete/Execute 9.x.

In this version, there was a TestIterator on the IntegrationObject, which made it possible to step through all tests of a project (regardless if test item, script unit, keyword tests). If you are working with version 9.x you can use this way.



I´m currently looking for a solution to get the defined keyword tests of a project through the com interface in the new major version 10.x. Are you still looking for a solution or did you find a way how to get this information?



Kind regards,

Marcus Simon 
Highlighted
Community Manager

RE: Getting Projects and Keyword Test information from TestExcecute COM object


Hi Marcus,


 


That's so cool!


If you posted your solution here, everybody in the community could see it and, perhaps, use it in future.


 

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Regular Contributor

RE: Getting Projects and Keyword Test information from TestExcecute COM object

The only practical way to do this is by reading the XML files themselves (.MDS, .PJS, etc..). The TestComplete COM interfaces are utterly incompetent in this regard, they are clearly just an automation layer on the UI, not a proper API. Even the XML files are pretty ugly, but you can manage them through the XDocument class and Linq.



Here is a very simple example on how to read the weird XML in TC project and project suite files:



    Public Function GetPJSProjects(ByVal pathProjectSuite As String) As List(Of String)

        Dim xDoc = XDocument.Load(pathProjectSuite)



        Return (From n In xDoc...<Node> Where n.@name = "files" Select n.<Node>.@name).ToList

    End Function[/xcode]



This would return any "name" property off "Node" nodes that are descendants of the "files" node. Obviously you will have to locate the information  you need within the XML tree and construct your Linq code accordingly, but this should get you started.
Highlighted
Community Hero

RE: Getting Projects and Keyword Test information from TestExcecute COM object

Hi Phil,



Some time ago I did a similair to what Hugo said parsing of TC project file to get a list of all manual tests that exist in the project. Hope you'll be able to modify the code (many thanks to SmartBear's Support for the help with it) to get the list of Keyword tests...


'-------------------------------------------------------------------------------



Function GetManualTestsCollection

  Const cProcName = "GetManualTestsCollection"

  Dim cProcNameMsgPrefix

  cProcNameMsgPrefix = cUnitNameMsgPrefix & cProcName & "(): "



  Const cExt = ".tcMT"



  Dim Doc

  Dim ManualTestCollection

  Dim Nodes

  Dim Node

  Dim strManTCName

  Dim i



  Set ManualTestCollection = CreateObject("Scripting.Dictionary")

  Set GetManualTestsCollection = ManualTestCollection



  If ("" = BuiltIn.GetCOMServerPath("Msxml2.DOMDocument.4.0")) Then InstallMSXML



  ' Create COM object

  Set Doc = Sys.OleObject("Msxml2.DOMDocument.4.0")

  Doc.async = False



  ' Load data from the current project file

  Call Doc.load(Project.FileName)



  ' Report an error, if, for instance, the markup or file structure is invalid

  If (Doc.parseError.errorCode <> 0) Then

    s = "Reason:" & vbTab & Doc.parseError.reason & vbCrLf & _

        "Line:"   & vbTab & CStr(Doc.parseError.line) & vbCrLf & _

        "Pos:"    & vbTab & CStr(Doc.parseError.linePos) & vbCrLf & _

        "Source:" & vbTab & Doc.parseError.srcText

    ' Post an error to the log and exit

    Call Log.Error(cProcNameMsgPrefix & "Error when parsing the project file.", _

        Project.FileName & vbCrLf & s)

    Set Doc = Nothing

    Exit Function

  End If



  ' Use an XPath expression to obtain the list of Manual tests nodes

'  Set Nodes = Doc.selectNodes("//Node[contains(@name,"".tcmt"")]")



  ' Return 'name' nodes that ends on cExt value (case insensitive compare)

  ' Case insensitive search for the 'name' nodes that end on the cExt ('.tcMT') extension

  ' Based on:

  ' http://stackoverflow.com/questions/614797/xpath-find-a-node-that-has-a-given-attribute-whose-value-c...

  ' http://www.dotnetspider.com/resources/470-Doing-case-InSensitve-comparisons-using-XPa-X.aspx

  ' http://bytes.com/topic/xml/answers/726552-xpath-query-ends

  Set Nodes = Doc.selectNodes("//Node[substring(translate(@name, ""abcdefghijklmnopqrstuvwxyz"", ""ABCDEFGHIJKLMNOPQRSTUVWXYZ""), string-length(@name) - string-length(""" & cExt & """) + 1, string-length(@name)) = translate(""" & cExt & """, ""abcdefghijklmnopqrstuvwxyz"",""ABCDEFGHIJKLMNOPQRSTUVWXYZ"")]")



  ' Process the nodes

  For Each Node In Nodes

    For i = 0 To Node.attributes.length-1

'      If ("value" = Node.attributes(i).name) Then

      If ("name" = Node.attributes(i).name) Then

        strManTCName = Node.attributes(i).text 'e.g. ManualTests\ManualTest1\ManualTest1.tcMT

          ' get file name (without path and ext.)

          strManTCName = Utilities.ChangeFileExt(aqFileSystem.GetFileName(strManTCName), "")

          If ("" <> strManTCName) Then ManualTestCollection.Add strManTCName, Eval(strManTCName)

      End If

    Next

  Next



  Set Doc = Nothing

End Function

'-------------------------------------------------------------------------------


Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
A new challenge is here!

Create a function to drag one element to another for the TechCorner tag!

Will you dare to take the challenge?


Scripts created in July:
- Passing custom command-line arguments as a test parameter
Top Kudoed Authors