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.

Take a Screen Shot function's Scope.

Akss004Akss004 Members
edited November -1 in Sahi - Open Source
narayan wrote:
I am not sure about a break point, but you can invoke a snapshot using this small function:
function takeSnapShot(){
    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("D:/path/snapshot.png");
        javax.imageio.ImageIO.write(image, "png", file);
    } catch (e) {
        print(e);
    }
}

// Call it
takeSnapShot();

This will work only if you are running tests in a single thread, since other windows may come on top of this during multithreaded playback.


Hi,

Just wanted to know something about this function. Does it uses any Windows utility or being a only JAVA entity it can work on linux as well.......??

Comments

This discussion has been closed.