Geeks With Blogs
Maryanne's Blog Another Geek with A Blog

I've been slogging away on an automation framework update for the last 4 work days.  What I have been working on is developing an action that will build an HTTP post for one of our functional applications.  Its been a challenge b/c of the data differences between the typical UI and the post.  For example, I can't pass in Years, I have to pass in a constant value of 2 for one of the post strings.

However, in the endeavor I discovered something FANTASTIC about QTP which made me want to shout WAHOOO...and here it is:

If you are working with DataTable columns, you can pass in variables for the data column names.  I didn't realize you could do this until yesterday but lord heaven does it make my life easier and here's why:

In the datasheet for this action I have the following columns, LoanAmount1, LoanAmount2, LoanAmount3.  Each of the values in the datasheet has to be added to a key in the post that looks like 1lamt=, 2lamt=, 3lamt=.

So I've been trying to figure out how to build a loop that would built the post for all three of them.  But I hit a snag with the datacolumn names....Until my fearless leader suggested I concatenate the column name sans numeric with an int  variable.

The code snipit therefore ends up looking something like this:

For i = 1 to offercount

strPutLR = strPutLR & "&" & i & "lamt=" & DataTable("LOANAMOUNT_OFFER" & i, dtLocalSheet)

Next 'i

I can do that loop for all of the parameters for each loan offer for as many loan offers as are included in the datasheet.  WOOOHOO.

Awesome Eh?

Oh and for the record the VBScript function "Replace" rocks.  I have to reformat the text provided so that spaces are replaced with "+" symbols.  So I was starting to think about building a function to do that.   I started digging through my VBscript reference book and found this.  AWESOME function.  So my reformatting code ends up looking like:

    strLoanType = DataTable("MORT_LOANTYPE_OFFER" & i, dtLocalSheet)
    strLoanType = Replace(strLoanType," ", "+")
    strPutLR = strPutLR & "&" & i & "offertype=" & strLoanType

Talk about handy!!!

Posted on Tuesday, October 23, 2007 9:17 AM QuickTest Pro | Back to top


Comments on this post: QTP Battles & Victories

# re: QTP Battles & Victories
Requesting Gravatar...
"mastering" I'm not sure about that. Maybe just a talented novice still.

:P
Left by MES on Oct 25, 2007 6:55 AM

Your comment:
 (will show your gravatar)


Copyright © Maryanne Sweat | Powered by: GeeksWithBlogs.net