Jump to content


How to write POST parameters to log file (Username, etc)


  • Please log in to reply
4 replies to this topic

#1 Guest_jbrinker_*

Guest_jbrinker_*
  • Guests

Posted 07 July 2010 - 03:08 PM

We are evaluating WAPTPRO 2.0 to possibly replace our current and expensive load testing software.

I have created our basic test script - log into our system, preform some actions, logout.
I am currently reading the username and "class number" from text files with 300 entries each. I did this by changing the parameter in the POST to
$LOrder(1,C:\Documents and Settings\jbrinker\Desktop\testcases298_users.txt)
and
$LOrder(1,C:\Documents and Settings\jbrinker\Desktop\testcases298_classs.txt)

One thing I need to be able to do, is to write the actual user and class being used into the log files. I tried to add a javascript object after the POST, but I can not figure how to get the values from above so I can write it to a log file. How can I write these values to the log on each iteration?

I'm sure we will have other questions, but this one is a show stopper for now.

Thanks!
Jeff

#2 Sergei Leonov

Sergei Leonov

    Advanced Member

  • Administrators
  • PipPipPip
  • 663 posts

Posted 08 July 2010 - 08:39 AM

POST parameters are logged during a test if you enable full logging. If you open a POST request in a log viewer, you can see POST parameters in the "Request" tab. Parameters will be after request header.
Sergei Leonov
WAPT Project Manager
SoftLogica LLC

Office: +7-383-335-6692
Toll-free: 1-888-364-6797 (for US only)
Time zone GMT +6, EST +11
E-mail: support@loadtestingtool.com
http://www.loadtestingtool.com

#3 Guest_jbrinker_*

Guest_jbrinker_*
  • Guests

Posted 08 July 2010 - 02:56 PM

QUOTE (Sergei Leonov @ Jul 8 2010, 03:39 AM) <{POST_SNAPBACK}>
POST parameters are logged during a test if you enable full logging. If you open a POST request in a log viewer, you can see POST parameters in the "Request" tab. Parameters will be after request header.


Thanks -

I see that is the case, however I don't want to have to enable full logging for our full tests (HUGE). I would like to be able to write to a seperate log file, or the regular log file. What I did do was:

Define variables early on in the script:

SYRuserid = $LOrder(1,C:\Documents and Settings\jbrinker\Desktop\testcases298_users.txt)
SYRclass = $LOrder(1,C:\Documents and Settings\jbrinker\Desktop\testcases298_classs.txt)

Then added java script:

log.message("SYR user: "+context.variable("SYRuserid")+"- SYR class no: "+context.variable("SYRclass"));

Now, will assigning those variables to the $LOrder of the text files cause it to "increment"? I.e. will the following page (which is the POST) use the same item in the ordered list that I assigned to the variable? This is what I want - to write out what is being used on this iteration.

What I would really like to do is, instead of using the regular logs, write to my own file. I am trying to figure out how to do that (Not a javascript programmer).

I have this so far, but its not working:

var fso = new ActiveXObject("Scripting.FileSystemObject");
var file = fso.CreateTextFile("c:\scriptLog.txt", True);
file.WriteLine("Hello World");
file.Close;

Once I get it working, I will just sub in variables for the Hello World part. I know this is pretty basic stuff, but I cant seem to get it to work.


#4 Guest_jbrinker_*

Guest_jbrinker_*
  • Guests

Posted 09 July 2010 - 02:00 PM

QUOTE (Sergei Leonov @ Jul 8 2010, 03:39 AM) <{POST_SNAPBACK}>
POST parameters are logged during a test if you enable full logging. If you open a POST request in a log viewer, you can see POST parameters in the "Request" tab. Parameters will be after request header.



OK... I think I have narrowed down the issue I have. I am trying to write using jscript to a log file. I make this simple test:

function WriteFile()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.CreateTextFile("c:\\Test.txt", true);
fh.WriteLine("Some text goes here...");
fh.Close();
}

WriteFile();

Initially, I got lots of "path not found" errors. I then realized that WAPT must be using the IE security settings, and that IE is not allowing activeX to write locally. So, I turn off ALL the activeX security for all zones in IE8. Now the script will run, but the file never is written.

If I place the script above in an HTML file, and try to load it in IE8, IE prompts me with "An ActiveX control might be unsafe to interact with other parts of the page. Do you want to allow this interaction?". If I click YES then script will execute and the file is written. I believe this prompt/security issue is causing WAPT to fail to write the file, just as it does when I test with IE8.

Since WAPT uses a local proxy to capture traffic, maybe if I were to add the local address to "trusted sites" it would work? I don't know what address WAPT acutally uses internally however. I have added localhost and the machine name to the trusted sites.

Any help appreciated here, this is really the major issue holding us back from a purchase.

Thanks
Jeff

#5 Sergei Leonov

Sergei Leonov

    Advanced Member

  • Administrators
  • PipPipPip
  • 663 posts

Posted 13 July 2010 - 09:53 AM

I use JavaScript operator (click on toolbar Add/JavaScript) with following code:

var ForReading = 1, ForWriting = 2, ForAppending = 8;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.OpenTextFile("F:\\Temp\\WAPT\\jbrinker\\test.txt",ForAppending,true);
fh.WriteLine(context.variable("v1"));
fh.Close();

It appends to test.txt value of v1 variable.

How do you use JavaScript function? Give me your profile, please.

Sergei Leonov
WAPT Project Manager
SoftLogica LLC

Office: +7-383-335-6692
Toll-free: 1-888-364-6797 (for US only)
Time zone GMT +6, EST +11
E-mail: support@loadtestingtool.com
http://www.loadtestingtool.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users