Saturday, February 18, 2012

LoadRunner has weird logging issue. While trying to only log when in the VuGen with JIT logging set as default, I could not programatically set the log level. I finally had to contact HP support which indirectly came up with the solution. Using the code below will set the log level to brief so you can track your test script while executing it in the VuGen, when running it in the controller, your logs will only show when an error occurs.



//if running in VuGen turn on logging
int vuserid;
lr_whoami(&vuserid, NULL, NULL);

if (vuserid == -1) {

// The lr_set_debug_message() function has a non-intuitive (i.e. stupid) behaviour,
// where it will automatically set LR_MSG_CLASS_JIT_LOG_ON_ERROR if your runtime
// settings have this option enabled. You must turn off JIT log as the last step.

lr_set_debug_message(LR_MSG_CLASS_BRIEF_LOG, LR_SWITCH_ON);
lr_set_debug_message(LR_MSG_CLASS_JIT_LOG_ON_ERROR, LR_SWITCH_OFF);

lr_output_message("Running in VuGen, turn on logging.");

}

Thursday, July 07, 2011

Decypt QTP Encrypted Passwords

Here's another code snippet that I've used extensively during my automation career. There are times in which you want to save a password with your test but don't want to expose that password for everyone to see. This can be done by using QTP's encryption utility. The problem here is that the decrypt functionality is built into QTP native objects only like WebEdit, VbEdit, etc. I've had to come up with my own solution to solve the problem of using an encrypted password on non native objects.

My solution is below. It's build off of a little trick that I got from another blog in which you can create an instance of IE that you then can use the WebEdit SetSecure method on. You then have the decrypted password you can use elsewhere in your application.





'''
''' Decrypts an string which has been encrypted using the Crypt.Encrypt() method.
'''

''' Code Source: http://quicktestprofessional.wordpress.com/2008/02/15/54/
''' The Encrypted String To decrypt
''' The specified string in un-encrypted form. Empty string will be returned if a problem was encountered.
Public Function Decrypt(StringToDecrypt)
Dim strRetVal
strRetVal = ""

Dim objIE
'need to launch a NEW instance of IE here...
Set objIE = CreateObject("InternetExplorer.Application")

' specify the IE settings
objIE.Navigate "about:blank"
objIE.Document.Title = "Decrypt"
objIE.ToolBar = False
objIE.Resizable = False
objIE.StatusBar = False
objIE.Width = 200
objIE.Height = 150
' Center the dialog window on the screen
With objIE.Document.ParentWindow.Screen
objIE.Left = (.AvailWidth - objIE.Width ) \ 2
objIE.Top = (.Availheight - objIE.Height) \ 2
End With

' Insert the HTML code for password box
objIE.Document.Body.InnerHTML = "

" & "Decrypt" & "

" _
& "

"

' Make the window visible
objIE.Visible = True

Dim objPasswordBox
Set objPasswordBox = Browser("name:=Decrypt").Page("title:=Decrypt").WebEdit("name:=txtDecrypt")
If Not (objPasswordBox Is Nothing) Then
objPasswordBox.SetSecure StringToDecrypt
strRetVal = objPasswordBox.getROProperty("value")
Browser("name:=Decrypt").Close
Else
Reporter.ReportEvent micFail, "Could not find a WebEdit of type password in the page."
End If

Set objPasswordBox = Nothing
Set objIE = Nothing

Decrypt = strRetVal
End Function

Tuesday, September 21, 2010

Downloading an attachment from the Test Resource Module in Quality Center 10.

I've been looking for a solution to how to download a file from the Test Resource module in QC10 and finally came up with a solution. This function will download the specified filename from a specific resource name. It will output this file to the path specified.





'''
''' Retrieves a resource from the Test Resource Module
'''
''' The resource name
''' The file name of the resource
''' The path to which to save the resource
''' Path including filename of the resource on the local filesystem.
Public Function GetAttachmentFromResource(ByVal ResourceName, ByVal FileName, ByVal OutPath)
Dim strRetVal
strRetVal = ""

Dim TDConnection
Set TDConnection = QCUtil.QCConnection

Dim ResourceFactory
Set ResourceFactory = TDConnection.QCResourceFactory

Dim ResourceFilter
Set ResourceFilter = ResourceFactory.Filter
ResourceFilter.Filter("RSC_NAME") = ResourceName
ResourceFilter.Filter("RSC_FILE_NAME") = FileName

Dim ResourceList
Set ResourceList = ResourceFactory.NewList(ResourceFilter.Text)

Dim intCount
intCount = ResourceList.Count

If intCount = 1 Then
ResourceList.Item(1).DownloadResource OutPath, True

strRetVal = OutPath & "\" & FileName
Else
Reporter.ReportEvent micWarning, "Multiple Resources Found", "There were " & intCount & " resources when looking for the resource named """ & ResourceName & """ with the filename """ & FileName & """."
End If
Set ResourceList = Nothing
Set ResourceFilter = Nothing
Set ResourceFactory = Nothing
Set TDConnection = Nothing

GetAttachmentFromResource = strRetVal
End Function

Wednesday, October 08, 2008

You want to know how much McCain and Obama's tax plan will really save you? Check it out: http://tinurl.us/fdab72

Monday, August 29, 2005


Well I got a challenge the other day from a co-worker. Apparently my athletic ability was challenged. I'm a bit of a geek and if you know geeks we don't play sports that much. I do play a little tennis and am trying to pick up golf.

After statements were made about how I don't play sports I stated I can bowl a little. So the challenge was made and off to Jillian's we went to bowl. It was sort of a late night at work so I asked another co-worker if he wanted to come along. He stated he needed to get his Bowling Balls and Shoes. Uh... Oh... Well it will be a fight for second :)

Long story short I won all three games we played. Even though I know I'm not the best I can beat any amateur claiming that he is so athletic he can play ANY sport :).

Thursday, August 11, 2005

Watch free HDTV with an outdoor antenna - CNET Weekend Project - CNET reviews

It seems CNET has made a nice video tutorial aobut how to find the right antenna and installing it for HDTV. This is just in time for the proposed analog TV cut off date of December 31, 2006.

Monday, July 25, 2005

CNN.com - NBC exec vows season of rebuilding - Jul 25, 2005

Now this is interesting. NBC has finally wised up and figured out viewers don't like the practice of starting and ending programs off the hour. This causes PVR's to see these shows as conflicting with other shows that start on the hour. This makes the user have to make a decision on what show they want to watch and I guess NBC has been getting the shaft. I guess last place is a place where you realize you can't be cocky anymore!