SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 6 of 6
  1. #1
    Member
    Join Date
    Sep 2006
    Posts
    82
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    How to load environment file from QC to the script

    I have environment file saved in QC test plan under some folder. Now I have a script which is also under QC in some folder. In the "Options" tab in QTP, I have the refference path included for this env file on where its loaded. But still I am not able to load the environment file through that script and the script is failing. This is what I have used in the script. I am using QTP 10.00 and QC 10.00.

    Environment.LoadFromFile ("[QualityCenter] Subject\Support Portal 5.1\Environment\Config.txt")

    When the script is executing from QC directly, its throwing error as

    File "[QualityCenter] Subject\Support Portal 5.1\Environment\Config.txt" could not be found.
    Line (1): "Environment.LoadFromFile "[QualityCenter] Subject\Support Portal 5.1\Environment\Config.txt"".

    Any help how to load this env file and make use of the data stored in that environment file.

    Thanks,
    Indranil

  2. #2
    Senior Member
    Join Date
    Feb 2003
    Posts
    533
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to load environment file from QC to the script

    If you have resource module, then store it in there. OR I use below approach. Have a function in which you pass path name and file name, it returns path where the file has been downloaded.
    Public Function QCDownloadAttachment(strPath, strFileName, ByRef strLocalDownloadPath)
    Dim TDConn, attFilter, result

    result = False

    'get a QC connection and login
    Set TDConn = QCMakeConnectionLogin("Production","AGI","qctroubl eshooter","")
    'retrieve the TreeManager that will be used to get the folder containing the attachment
    Set treeMng = TDConn.TreeManager
    'retrieve the folder Node
    Set sourceFolder = treeMng.NodeByPath(strPath)
    'get the attachment factory and use it to retrieve the list of attachements in the folder
    Set attachFact = sourceFolder.Attachments
    Set list = attachFact.NewList("")
    'get the count of attachments in the folder.
    attCount = list.Count
    'Loop through attachments and download attachement if name matches
    For i = 1 to attCount
    Set att = list.Item(i)
    s = s & att.Name(1) & vbCrLf
    If att.Name(1) = strFileName Then
    'attachment file name matches so download file
    att.Load True, ""
    strLocalDownloadPath = att.FileName
    QCDownloadAttachment = True
    Exit Function
    End If
    Next

    QCDownloadAttachment = result

    End Function
    ''''''''''''''''''''''''''
    Private Function QCMakeConnectionLogin(strDomain, strProject, username, password)
    Dim tdc
    Const qcServer = "http://XXXXXX:8080/qcbin"

    On Error Resume Next

    'If user is already connected to QC then use the existing connection
    If QCUtil.IsConnected Then
    Set QCMakeConnectionLogin = QCUtil.QCConnection
    Exit Function
    End If

    'get the TDConnection object
    Set tdc = CreateObject("TDApiOle80.TDConnection.1")
    'make connection to QC server
    tdc.InitConnectionEx qcServer
    'check if user is logged in. If not then log in
    If tdc.LoggedIn = False Then
    'authenticate to QC
    tdc.Login username, password
    'login to domain and project
    tdc.Connect strDomain, strProject
    End If


    If Err.Number<> 0 Then
    ErrHandler err, fName, err.Description & vbCrLf & errmsg
    Set QCMakeConnectionLogin = Nothing
    Else
    Set QCMakeConnectionLogin = tdc
    End If

    End Function
    ''''''''''''''''''''''''
    And here is he usage
    downloadStatus = QCDownloadAttachment("Subject\Automation\Framework \Repositories\", "Data_Repository.xls", strlocalPath)
    If downloadStatus = True Then
    localDataRepositoryPath = strlocalPath
    Else
    Reporter.ReportEvent micFail, "Download Repositories", "Repository [Subject\Automation\Framework\Repositories\Data_Rep ository.xls] could not be downloaded"
    End If

  3. #3
    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: How to load environment file from QC to the script

    Are you sure this is a txt file?
    Rajkumar

  4. #4
    Member
    Join Date
    Sep 2006
    Posts
    82
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to load environment file from QC to the script

    Yes, its a txt file. I tried with xml and ini file types also, but same error i was getting.

  5. #5
    Member
    Join Date
    Sep 2006
    Posts
    82
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to load environment file from QC to the script

    Thanks a ton [img]/images/graemlins/smile.gif[/img]

    Yes, I have resource tab enabled in QC. But i am not sure if I store my scripts and other related stuffs (like env file, datasheet, repository etc) there, how can i execute the script directly from QC?

  6. #6
    Senior Member
    Join Date
    Feb 2003
    Posts
    533
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to load environment file from QC to the script

    [ QUOTE ]
    Thanks a ton [img]/images/graemlins/smile.gif[/img]

    Yes, I have resource tab enabled in QC. But i am not sure if I store my scripts and other related stuffs (like env file, datasheet, repository etc) there, how can i execute the script directly from QC?

    [/ QUOTE ]

    As usual I have scripts in test plan. Associated data tables are in resources. It works fine! BTW I am not using QTP OR, but an excel sheet that I call as object repository. You can have your resources residing in resources and still associate with your QTP scripts.

 

 

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.71%
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 12:34 PM.

Copyright BetaSoft Inc.