18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

On error taking the Screenshot and printing the Trace to Log

ravillaravilla Members
edited November -1 in Sahi - Open Source
Hello Narayan,


Do we have a chance to take the Screenshot of the page when script failed and capturing of the error details.

If there please let me know,as our client is intertesed on that.

Regards
Anil Kumar R

Comments

  • sakkusakku Members
    Hi Friend ,

    I had use the following function and is working fine

    function takeSnapShot($filename)
    {
    try
    {
    var robot = new java.awt.Robot();
    var toolkit = new java.awt.Toolkit.getDefaultToolkit();
    var screenSize = toolkit.getScreenSize();
    var screenRect = new java.awt.Rectangle(0, 0, screenSize.width, screenSize.height);
    var image = robot.createScreenCapture(screenRect);

    var file = new java.io.File("C://Documents and Settings//dmc013//sahi//userdata//scripts//"+$filename+".png"); // Here you can use your required directory


    javax.imageio.ImageIO.write(image, "png", file);
    }
    catch (e)
    {
    print(e);
    }
    }

    // you just call this function

    takeSnapShot("snapshot");
Sign In or Register to comment.