1 comment

  • Avatar
    Prateek Kumar Baheti

    Currently there is no way to disable screenshots on Failure in Twist. The screenshots are not taken only if tests are running on a headless environment.

    Though there is a  way to take custom screenshots in Twist. It be done by wiring "CustomScreenshotListener". This is an interface that Twist exposes with a method

         public void captureScreenshot(File directory, String screenshotFileName) 

    You can write a class that implements this interface and captures a screenshot with the fileName and in the directory name provided as arguments. This screenshot can be taken via webdriver in your case.


      public class MyScreenshotListener implements CustomScreenshotListener {    


          private WebDriver browser;  //Autowire if needed

          public void captureScreenshot(File directory, String fileName) {

              // Take screenshot here





    To register this screenshotListener you need to add beans in the applicationContext-suite.xml in the Twist project like below.


    <bean id="myScreenshotListener" class="">



    <bean id="screenshotListener" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">

            <property name="targetClass" value=""/>

            <property name="targetMethod" value="addCustomScreenshotListener"/>

            <property name="arguments">


                     <ref bean="myScreenshotListener"/>




    This will add the custom screenshots to the generated reports. Though not documented, this is an easy way to hook custom screenshots into Twist.


    Comment actions Permalink

Please sign in to leave a comment.