Jump to content
WAPT Forum
Sign in to follow this  
Guest jbrinker

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

Recommended Posts

Guest jbrinker

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Guest jbrinker
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.

 

Share this post


Link to post
Share on other sites
Guest jbrinker
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

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×