SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 7 of 7
  1. #1
    Apprentice
    Join Date
    Aug 2010
    Posts
    40
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Add A File to a test set via the OTA_API

    I am new to coding the OTA_API and have been tasked with the following.

    Description of issue: I m attempting to do a couple of things with the following code.

    1. Connect to QC
    2. Navigate to the correct project
    3. Select the appropriate Test Set from the project
    4. Loop through the Test is the test set to update the pass/fail.


    5. Finally after the test run has completed upload an excel file as an attached file with further information about the test run.

    I am having trouble with #5.

    Environment:

    QC 10

    Any input would be appreciated. Please forgive the messiness of the code I am new to this and it is a rough rough version. All constructive criticism is appreciated and encouraged!!

    Thanks,

    Jim

    <font class="small">Code:</font><hr /><pre> Dim tdc
    Dim strQCHostName
    Dim strTestSet
    Dim tset
    Dim strQCCon
    Dim tstMgr
    Dim tsttr
    Dim tsetFact
    Dim tsetList
    Dim strError
    Dim strtesttest
    Dim tsFolder
    Dim tsTestFactory
    Dim tsTestList
    Dim strtesttest1
    Dim strTestFolder

    'Constants
    Const qcServer = "http://dummy.dummy.com:8080/qcbin"
    Const qcDomain = "OTHER"
    Const qcProject = "End_To_End_Test" 'Please define here the name of the project
    Const qcUser = "User" 'Please define here the username
    Const qcPassword = "PW" 'Please define here the password

    strTestFolder = "Root\Dummy_Reporting_TS"
    strTestSet = "Set1"

    Set tdc = CreateObject("TDApiOle80.TDConnection.1")
    tdc.InitConnectionEx qcServer
    tdc.Login qcUser, qcPassword
    tdc.Connect qcDomain, qcProject
    strQCCon = tdc.Connected
    MsgBox strQCCon
    'Get test set

    If strQCCon = True Then

    'get test set

    Dim tsFactory
    'TestSetFactory
    Set tsFactory = tdc.TestSetFactory
    'TestSetTreeManager
    Dim tsTreeMgr
    Set tsTreeMgr = tdc.TestSetTreeManager
    'TestSetFolder
    'Dim tsFolder
    Set tsFolder = tsTreeMgr.NodeByPath(strTestFolder)
    'List of Test Sets
    Dim tsList
    Set tsList = tsFolder.FindTestSets(strTestSet)

    'loop through the test sets

    For Each TestSet in tsList
    'TestSetFolder
    ' Dim tsFolder
    Set tsFolder = TestSet.TestSetFolder 'TestSetFolder
    MsgBox tsFolder
    'Dim tsTestSetName
    'Set tsTestSetName = TestSet.Name
    'Msgbox tsTestSetName
    'TSTestFactory
    ' Dim tsTestFactory
    Set tsTestFactory = TestSet.TSTestFactory
    'List of tests
    'Dim tsTestList
    Set tsTestList = tsTestFactory.NewList("")

    'loop through tests

    For Each tsTest in tsTestList
    Dim strTestName1
    strTestName1 = tsTest.Name
    MsgBox strTestName1
    'Last Run
    Dim lastRun
    Set lastRun = tsTest.LastRun
    'Msgbox lastRun
    'don't update test if it may have been modified by someone else

    If Not IsNull (lastRun) Then
    'RunFactory
    Dim runFactory
    Set runFactory = tsTest.RunFactory
    Dim strDate
    strDate = "20120823230000"
    'DateTime.Now.ToString("yyyyMMddhhmmss")
    'Create test run
    Dim run
    Set run = runFactory.AddItem("Run_" &amp; strDate)
    run.Status = "Failed"
    run.Post()
    End If

    Next

    'Attach excel file to the Test Set
    Dim AttFact
    Set AttFact = tdc.AttachmentFactory
    Dim Att
    Set Att = tdc.Attachment
    AttFact = TestSet.Attachments
    Dim Args(0
    Dim 1)
    Args(0) = "C:\dummy\testset.xlsx" 'HTMLSummaryFilename ' Full path to the file here
    Args(1) = 1 ' tagTDAPI_ATTACH.TDATT_COPY indicates copy to server
    Set Att = AttFact.AddItem(Args)
    Att.Post()


    'Original add attachement code
    'Dim AttFact As TDAPIOLELib.AttachmentFactory
    'Dim Att As TDAPIOLELib.Attachment
    'AttFact = TestInstance.Attachments
    'Dim Args As Variant(0 to 1)
    'Args(0) = HTMLSummaryFilename ' Full path to the file here
    'Args(1) = 1 ' tagTDAPI_ATTACH.TDATT_COPY indicates copy to server
    'Set Att = AttFact.AddItem(Args)
    'Att.Post()



    Next

    'Release the TDConnection object.
    tdc.ReleaseConnection
    ''Check status (For illustrative purposes.)
    Set tdc = Nothing
    Else
    strError = "QC Connection Not Made"
    MsgBox strError
    End If
    </pre><hr />

  2. #2
    Advanced Member
    Join Date
    Nov 2006
    Posts
    821
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0

    Re: Add A File to a test set via the OTA_API

    Please clarify exactly which entity you want to attach the file to - Test Set, Test Instance (a.k.a. Test Set Test), or Test Instance Run?

    Your code shows you attempting to attach the file to the Test Set. You code that you commented out appears to show you trying to attach the file to the Test Instance.

    And, exactly what is happening that is not what you expect/want? Are you getting errors?
    Trudy C
    (Opinions and information contained in this post are wholly my own and do not reflect the opinions of my employer.)

  3. #3
    Apprentice
    Join Date
    Aug 2010
    Posts
    40
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Add A File to a test set via the OTA_API

    Trudy,

    Thanks for your response. I used the commented out code as a guide to try and create the attachment. I want it to the Test Set.


    The code I have posted is what I could find that was indicated to work. I have been trying to modify it to add the file to the test set.

    Jim

  4. #4
    Apprentice
    Join Date
    Aug 2010
    Posts
    40
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Add A File to a test set via the OTA_API

    So the code that causes the problems is the code I modified below. I get object doesn't support this method errors on the following lines.

    Lines with the *** are failing.
    <font class="small">Code:</font><hr /><pre>
    Dim AttFact
    ***'Set AttFact = TestSet.AttachmentFactory
    Dim Att
    ***'Set Att = TestSet.Attachment
    'AttFact = TestSet.Attachments

    I get a subscript out of range error on the lines below.
    ****Dim Args(0,1)
    Args(0) = "C:\dummy\testset.xlsx" 'HTMLSummaryFilename ' Full path to the file here
    Args(1) = 1 ' tagTDAPI_ATTACH.TDATT_COPY indicates copy to server
    Set Att = AttFact.AddItem(Args)
    Att.Post()

    </pre><hr />

  5. #5
    Advanced Member
    Join Date
    Nov 2006
    Posts
    821
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0

    Re: Add A File to a test set via the OTA_API

    Using your copy of the sample code, try this:

    <font class="small">Code:</font><hr /><pre>
    'Attach excel file to the Test Set
    Dim AttFact
    Dim Att
    Dim Args As Variant(0 to 1)
    Set AttFact = TestSet.Attachments
    ' Full path to the file here
    Args(0) = "C:\dummy\testset.xlsx" 'HTMLSummaryFilename
    ' tagTDAPI_ATTACH.TDATT_COPY = 1 = copy to server
    Args(1) = 1
    Set Att = AttFact.AddItem(Args)
    Att.Post()
    </pre><hr />
    Trudy C
    (Opinions and information contained in this post are wholly my own and do not reflect the opinions of my employer.)

  6. #6
    Member
    Join Date
    Jan 2009
    Location
    Canberra
    Posts
    273
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Add A File to a test set via the OTA_API

    [ QUOTE ]

    <font class="small">Code:</font><hr /><pre>

    Dim Args(0,1)' This is wrong. creating a 2d array.
    ' you want a one D array with two elements
    ' try
    Dim Args(2)

    </pre><hr />

    [/ QUOTE ]

    The Dim as variant suggested by Trudy will not work in VBscript because you do not dim as anything in VBscript.

  7. #7
    Moderator
    Join Date
    Oct 2010
    Location
    Norway
    Posts
    3,265
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Re: Add A File to a test set via the OTA_API

    You don't need an array there.

    Try this.

    <font class="small">Code:</font><hr /><pre>
    Function addAttachmentToCurrentRun (strAttachmentFileName)

    If QCUtil.IsConnected Then
    Set CurrentRun =QCUtil.CurrentRun
    Set attachment = CurrentRun.Attachments
    Reporter.ReportEvent micDone, "Attachment Saved to QC run data", strAttachmentFileName
    Set att = attachment.AddItem(Null)
    att.FileName = strAttachmentFileName
    att.Type = 1
    att.Post
    att.Save False
    Else
    Reporter.ReportEvent micWarning, "Attachment Not Saved to QC", "Not connected to Quality Center"
    End If

    End Function</pre><hr />

    I suggest that you refer the OTA Reference documention in ALM/QC Documentation Library, for examples &amp; details on the methods &amp; properties.
    Rajkumar

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.00%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 06:59 PM.

Copyright BetaSoft Inc.