{"id":102,"date":"2025-09-06T10:12:50","date_gmt":"2025-09-06T10:12:50","guid":{"rendered":"https:\/\/blog.kerjarapi.com\/?p=102"},"modified":"2025-09-06T10:14:06","modified_gmt":"2025-09-06T10:14:06","slug":"screenshots-and-recordings-in-katalon-studio","status":"publish","type":"post","link":"https:\/\/blog.kerjarapi.com\/?p=102","title":{"rendered":"Screenshots and Recordings in Katalon Studio"},"content":{"rendered":"\n<p>Yes, you can automate the process of recording your Katalon Studio test executions by combining Katalon Studio with a screen recording tool that supports command-line options. Here&#8217;s a general approach to achieve this:<\/p>\n\n\n\n<p>Note: this was created and tested using Windows 11 and Katalon 8.6.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Use <strong>OBS Studio<\/strong> with Katalon Studio:<\/h3>\n\n\n\n<p><strong>OBS Studio<\/strong> is a popular open-source screen recording software that can be automated using scripts and command-line arguments. You can integrate this with Katalon Studio so that OBS starts recording automatically when you run your automation test.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Steps to Automate Recording with OBS Studio:<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Install OBS Studio<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Download and install OBS from <a href=\"https:\/\/obsproject.com\/\" target=\"_blank\" rel=\"noopener\">obsproject.com<\/a>.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Set Up OBS Studio<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Open OBS and configure your scene for screen recording (e.g., select Display Capture).<\/li>\n\n\n\n<li>Save your settings.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Use Command-Line Options in OBS<\/strong>: OBS can be controlled via the command line. To start and stop recording automatically, use the following commands:\n<ul class=\"wp-block-list\">\n<li>To <strong>start recording<\/strong>: <code>bash Copy code obs64.exe --startrecording --minimize-to-tray<\/code><\/li>\n\n\n\n<li>To <strong>stop recording<\/strong>: <code>bash Copy code obs64.exe --stoprecording<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Create Custom Katalon Test Listener<\/strong>: In Katalon Studio, you can use a <strong>Test Listener<\/strong> to execute commands before and after test execution. This way, you can automatically start and stop OBS recording when a test starts and ends.\n<ul class=\"wp-block-list\">\n<li>Go to the <strong>Test Listeners<\/strong> section in Katalon Studio and create a new listener.<\/li>\n\n\n\n<li>Add the following code to <strong>start recording<\/strong> before the test: <br><br><code>import com.kms.katalon.core.annotation.BeforeTestCase<br>import com.kms.katalon.core.context.TestCaseContext<br><br>class TestListener {<br>  @BeforeTestCase<br>  def startRecording(TestCaseContext testCaseContext) {<br>    def command = \"cmd \/c start obs64.exe --startrecording --minimize-to-tray\"<br>    Runtime.getRuntime().exec(command)<br>  }<br>}<\/code><br><\/li>\n\n\n\n<li>Add the following code to <strong>stop recording<\/strong> after the test: <br><br><code>import com.kms.katalon.core.annotation.AfterTestCase<br>import com.kms.katalon.core.context.TestCaseContext<br><br>class TestListener {<br>  @AfterTestCase<br>  def stopRecording(TestCaseContext testCaseContext) {<br>    def command = \"cmd \/c start obs64.exe --stoprecording\"<br>    Runtime.getRuntime().exec(command)<br>  }<br>}<\/code><br><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Run the Test<\/strong>:\n<ul class=\"wp-block-list\">\n<li>When you run your Katalon Studio test, the custom test listener will trigger the start and stop commands for OBS, automatically recording your test execution.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Use <strong>ffmpeg<\/strong> for Automated Screen Recording:<\/h3>\n\n\n\n<p>You can also use <strong>ffmpeg<\/strong>, a powerful command-line tool for video recording, to automate the process. Like OBS, ffmpeg can be triggered with Katalon\u2019s Test Listeners.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Install ffmpeg<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Download and install from <a href=\"https:\/\/ffmpeg.org\/download.html\" target=\"_blank\" rel=\"noopener\">ffmpeg.org<\/a>.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Set Up ffmpeg Command<\/strong>:\n<ul class=\"wp-block-list\">\n<li>To start recording using ffmpeg, use a command like this: <code>bash Copy code ffmpeg -y -f gdigrab -framerate 30 -i desktop output.mp4<\/code><\/li>\n\n\n\n<li>To stop recording, you need to kill the process. This can be automated via Test Listeners, similar to OBS.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Integrate ffmpeg with Katalon Studio<\/strong>:\n<ul class=\"wp-block-list\">\n<li>In the <strong>Test Listeners<\/strong> in Katalon, you can execute the ffmpeg command to start and stop the recording as part of the test lifecycle.<br>Example Test Listener implementation:<br><br><code>import com.kms.katalon.core.annotation.BeforeTestCase<br>import com.kms.katalon.core.annotation.AfterTestCase<br>import com.kms.katalon.core.context.TestCaseContext<br><br>class TestListener {<br>  Process ffmpegProcess<br><br>  @BeforeTestCase<br>  def startRecording(TestCaseContext testCaseContext) {<br>    def command = [\"ffmpeg\", \"-y\", \"-f\", \"gdigrab\", \"-framerate\", \"30\", \"-i\", \"desktop\", \"output.mp4\"]<br>    ProcessBuilder pb = new ProcessBuilder(command)<br>    pb.redirectErrorStream(true)<br>    ffmpegProcess = pb.start()<br>    println \"FFmpeg started for recording...\"<br>  }<br><br>  @AfterTestCase<br>  def stopRecording(TestCaseContext testCaseContext) {<br>    if (ffmpegProcess != null &amp;&amp; ffmpegProcess.isAlive()) {<br>      ffmpegProcess.destroy()<br>      ffmpegProcess.destroyForcibly()<br>      println \"FFmpeg stopped recording.\"<br>    }<br>  }<\/code><\/li>\n\n\n\n<li>You can make recordings unique for each test case by saving them with the test case name:<br><br><code>@BeforeTestCase<br>def startRecording(TestCaseContext testCaseContext) {<br>  def testName = testCaseContext.getTestCaseId().replaceAll(\"[^a-zA-Z0-9-_]\", \"_\")<br>  def outputFile = \"recordings\/${testName}.mp4\"<br>  new File(\"recordings\").mkdirs()<br><br>  def command = [\"ffmpeg\", \"-y\", \"-f\", \"gdigrab\", \"-framerate\", \"30\", \"-i\", \"desktop\", outputFile]<br>  ProcessBuilder pb = new ProcessBuilder(command)<br>  pb.redirectErrorStream(true)<br>  ffmpegProcess = pb.start()<br>}<\/code><br><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>With either <strong>OBS Studio<\/strong> or <strong>ffmpeg<\/strong>, you can automatically record your test execution in Katalon Studio, making debugging and sharing test runs much easier.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yes, you can automate the process of recording your Katalon Studio test executions by combining Katalon Studio with a screen recording tool that supports command-line options. Here&#8217;s a general approach to achieve this: Note: this was created and tested using Windows 11 and Katalon 8.6. 1. Use OBS Studio with Katalon Studio: OBS Studio is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,7],"tags":[],"class_list":["post-102","post","type-post","status-publish","format-standard","hentry","category-en","category-katalon-auto"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=\/wp\/v2\/posts\/102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=102"}],"version-history":[{"count":1,"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions"}],"predecessor-version":[{"id":103,"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions\/103"}],"wp:attachment":[{"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}