18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
_takeScreenShot() works great, except that it only works on single screen setup...
Best Answer
-
I'm using Sahi Open Source, so I don 't believe _takeScreenShot() is available to me. I use a Java function instead. This takes a screenshot of BOTH monitors.
//
function takeErrorSnapShotDualRight(){
var $fileName = "R_Error_";
var robot = new java.awt.Robot();
var toolkit = new java.awt.Toolkit.getDefaultToolkit();
var screenSize = toolkit.getScreenSize();
var screenRect = new java.awt.Rectangle(1919, 0, screenSize.width / 2, screenSize.height);
var image = robot.createScreenCapture(screenRect);
d = new Date();
var tm = d.toString('HH:mm:ss');
printAnyThroughJava("The Time is "+tm);
ctr++;
var file = new java.io.File($screenShotPath +$funcName +$fileName +"Screenshot_" + tm + "_" + ctr + ".png");
javax.imageio.ImageIO.write(image, "png", file);
}
//
function takeErrorSnapShotDualLeft(){
var $fileName = "L_Error_";
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 / 2, screenSize.height);
var image = robot.createScreenCapture(screenRect);
d = new Date();
var tm = d.toString('HH:mm:ss');
ctr++;
var file = new java.io.File($screenShotPath +$funcName +$fileName +"Screenshot_" + tm + "_" + ctr + ".png");
javax.imageio.ImageIO.write(image, "png", file);
}

Answers
Although, the final environment is headless in my case. the screenshots is only for debugging.
I make use of a small function:
function $ScreenGrab(){
_set($dt, document.title); // this will take window title
_focusWindow($dt); // this will set the focus on window
_takeScreenShot(); // this will take the snapshot
};
Think Ill give it a go. Thanx