2

I wrote one selenium automation javascript in JMeter using a webdriver sampler.

In that, I try to find the total time taken for traversing from first page to last page of the website.

To print time or particular message I used WDS.log.info() function.

When running this script I got output in the .log file. Now, I want to save every log file separately for every transaction?

How we can achieve this?

Or is there any other idea to print or save my script result (which was generated in the log file) in a new file with each transaction?

1
  • There are a number of built in components that can write output from jmeter, or you can simply write your own. I would like to know more about your tooling approach... "selenium automation javascript in JMeter using a webdriver sampler". Are you planning to use this script for performance testing ? At first glance, this seems like an odd combination of tools.
    – ToastMan
    Commented May 16, 2022 at 14:05

1 Answer 1

2

If you want to print arbitrary data to the separate file you can do something like:

org.apache.commons.io.FileUtils.writeStringToFile(new java.io.File('somefile.log'), 'some-data', 'UTF-8', true)

see the FileUtils.writeStringToFile() JavaDoc for more information.

If you're going to run multiple threads a better idea would be using a JMeter Listener like Flexible File Writer for thread safety. Flexible File Writer listener can be installed using JMeter Plugins Manager

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.