Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Any option to copy/download from HPQC to local path...pls help
#1
Hi,

There is one file(.jar file) as an attachment in a folder under Testplan tab in HPQC
I need to download this file from HPQC to local drive of our PC

is there any option to copy/move/download from QC to our local PC
by coding
or any option to run these (.Jar file) from QC path?????


pls reply me if anyone has solution for it..


Thanks

Remya
Reply
#2
Here's a function to download attachments from QC. It will only work for attachments in the Test Plan module, but that should work for you.

Code:
'@Description Downloads specified attachment from QC. Specify the fully qualified QC path, ex. "Subject\Utilities\Test.txt". Returns the local file path. Public Function LoadAttachment(ByVal attachmentPath) Dim node, attachmentFilter, attachmentList, attachment, nodePath, fileName nodePath = Left(attachmentPath, InStrRev(attachmentPath, "\") - 1) fileName = Right(attachmentPath, Len(attachmentPath) - InStrRev(attachmentPath, "\")) Set node = QCUtil.TDConnection.TreeManager.NodeByPath(nodePath) Set attachmentFilter = node.Attachments.Filter attachmentFilter.Filter("CR_REFERENCE") = "'ALL_LISTS_" & node.NodeID & "_" & fileName & "'" Set attachmentList = attachmentFilter.NewList If attachmentList.Count = 1 Then Set attachment = attachmentList.Item(1) 'Create a dialog to show while attachment is loading if not running from QC If QcUtil.CurrentTestSet Is Nothing And QcUtil.CurrentRun Is Nothing Then Dim dialogForm, dialogStartPosition, dialogBorderStyle, dialogLabel, dialogFont, dialogContentAlign, hWnd, intPtrHWnd, qtpWnd Set dialogForm = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms") Set dialogStartPosition = DotNetFactory.CreateInstance("System.Windows.Forms.FormStartPosition", "System.Windows.Forms") Set dialogBorderStyle = DotNetFactory.CreateInstance("System.Windows.Forms.FormBorderStyle", "System.Windows.Forms") Set dialogLabel = DotNetFactory.CreateInstance("System.Windows.Forms.Label", "System.Windows.Forms") Set dialogFont = DotNetFactory.CreateInstance("System.Drawing.Font", "System.Drawing", "Microsoft Sans Serif", 11) Set dialogContentAlign = DotNetFactory.CreateInstance("System.Drawing.ContentAlignment", "System.Drawing") dialogForm.Width = 280: dialogForm.Height = 100: dialogForm.ControlBox = False: dialogForm.StartPosition = dialogStartPosition.CenterScreen dialogForm.FormBorderStyle = dialogBorderStyle.FixedDialog: dialogForm.Text = "Downloading Attachment From Quality Center..." dialogLabel.Width = 260: dialogLabel.Height = 80: dialogLabel.Top = 0: dialogLabel.Left = 10: dialogLabel.Font = dialogFont dialogLabel.TextAlign = dialogContentAlign.MiddleCenter: dialogLabel.Text = "Downloading " & fileName & " From Quality Center, Please Stand By..." dialogForm.Controls.Add dialogLabel hWnd = Window("RegExpWndTitle:=QuickTest Professional").GetROProperty("hWnd") Set intPtrHWnd = DotNetFactory.CreateInstance("System.IntPtr", "Mscorlib", hWnd) Set qtpWnd = DotNetFactory.CreateInstance("System.Windows.Forms.NativeWindow", "System.Windows.Forms") qtpWnd.AssignHandle intPtrHWnd dialogForm.Show qtpWnd: dialogForm.Refresh() End If 'Load attachment attachment.Load True, "" 'Get rid of the dialog if not running from QC If QcUtil.CurrentTestSet Is Nothing And QcUtil.CurrentRun Is Nothing Then dialogForm.Close: dialogForm.Dispose Set dialogContentAlign = Nothing: Set dialogFont = Nothing: Set dialogLabel = Nothing: Set dialogBorderStyle = Nothing Set dialogStartPosition = Nothing: Set dialogForm = Nothing: Set intPtrHWnd = Nothing: Set qtpWnd = Nothing End If LoadAttachment = attachment.FileName ElseIf attachmentList.Count = 0 Then Err.Raise 17, "Load Attachment", fileName & " File Not Found!" Else Err.Raise 17, "Load Attachment", "Unknown Error Loading " & fileName & "!" End If Set node = Nothing Set attachmentFilter = Nothing Set attachmentList = Nothing Set attachment = Nothing End Function

To run a Java JAR file with the above function, you can do something like:

Code:
Dim jarPath: jarPath = LoadAttachment("Subject\Test.jar") Dim folderPath: folderPath = Left(jarPath, InStrRev(jarPath, "\")-1) Dim wsh: Set wsh = CreateObject("WScript.Shell") wsh.Run "cmd /c cd " & folderPath & "&&java -jar " & jarPath, 10, True

I have not tested the second piece of code though, so you might get some errors you will have to work through. However, this should at least give you an idea of how to do what you want. Search for "WScript.Shell" and how to concat command line commands to find out what this code does.

Hope this helps!!!

P.S. Don't forget to release the objects in your final code!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to get relative path by using testdir environment variable Sathyaprasad 1 2,454 11-30-2017, 02:21 AM
Last Post: supputuri
  Should I download every patch in order to UFT recognize the Chrome and FireFox browse jesusisaac 6 6,358 08-25-2016, 05:03 PM
Last Post: Ankesh
  Path of Flight reservation Window is not recorded in HP UFT 12.52 version mailtokopalverma@gmail.com 1 3,271 04-01-2016, 05:34 PM
Last Post: vinod123
  Local System Monitor kbhargava505 0 2,818 10-16-2015, 12:52 PM
Last Post: kbhargava505
  How to select the drop down option by searching for partial text Neetha 4 9,912 08-04-2015, 08:55 PM
Last Post: Neetha

Forum Jump:


Users browsing this thread: 1 Guest(s)