HomeSUPPORT QUESTIONS

Need help with StresStimulus? Start here.

Write Extractor value into CSV/Txt file using C# Messages in this topic - RSS

PreetiTester
PreetiTester
Posts: 6


2/19/2020
PreetiTester
PreetiTester
Posts: 6
Hi Folks ,

Need help on how to write an extractor value into CSV or txt file using C# Code. I don't want to use "Advanced Option" of output text file as the file name generated is based on timestamp. I want file name to be fixed.I will be using this .txt file as input in another Stress Stimulus script.
Also how to ensure that this file is written at End Of iteration for each user ?
0 link
George @StresStimulus
George @StresStimulus
Administrator
Posts: 287


2/21/2020
George @StresStimulus
George @StresStimulus
Administrator
Posts: 287
In order to achieve your requirements, you would need to create an external component that is described http://support.stresstimulus.com/display/doc51/Creating+External+Components


You would need to implement the OnAfterIteration method. See the sample C# code below.


public class MyExternalComponent : IExternalComponent
{
Static object FileWriteLock = new object();
public void OnAfterIteration(RuntimeVU vu)
{
//--- Get the custom extractor format you want to write to file. Use ExtractorRuntime to access extractor values. http://support.stresstimulus.com/display/doc51/ExtractorRuntime
StringBuilder sb = new StringBuilder();
sb.AppendLine(vu.ExtractorRuntime.GetExtractorValue(“extrator1”))
sb.AppendLine(vu.ExtractorRuntime.GetExtractorValue(“extrator2”))

//--- Write to file. Remember to use file locks
lock(FileWriteLock)
{
using (StreamWriter outputFile = new StreamWriter(“my_file_path.txt”)) // replace file path with desired name
{
outputFile.Write(sb.ToString());
}
}
}
}
0 link
PreetiTester
PreetiTester
Posts: 6


2/24/2020
PreetiTester
PreetiTester
Posts: 6
Thanks for the reply @George. So i will have to setup Visual studio and .NET Framework for using external components ? Sure will give it a try and keep you posted for success/failure/issues .
0 link
PreetiTester
PreetiTester
Posts: 6


2/24/2020
PreetiTester
PreetiTester
Posts: 6
I have one more question - How do I disable URL encoding for hard coded Request Parameters being sent along with request ? I can see from Stress stimulus docs that we can disable URL Encoding for Extractors but how to do it for Hard Coded Request Parameters ? I Notice
In Recorded request it is - http://
In replayed request it becomes - http%3A%2F%2F
0 link
George @StresStimulus
George @StresStimulus
Administrator
Posts: 287


2/24/2020
George @StresStimulus
George @StresStimulus
Administrator
Posts: 287
StresStimulus handles Url encoding automatically. In most situations, script playback errors are caused by various issues unrelated to Url encoding. For that reason, to protect end-users from manually selecting incorrect Url encoding options, they are not exposed in the UI. For customers, we resolve any scripting issues on screen sharing sessions.

If you are evaluating StresStimulus and getting playback errors and interested in a screen sharing support session, email us at support@stresstimulus.com, and we will assist you.
0 link






Copyright © 2020 Stimulus Technology