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.
Take screenshots with Sahi
Hi,
Is it possible to insert "brake point" in Sahi script to request a screenshot of browser window under test?
Similar solution was developed for Selenium (binil.wordpress.com/2006/12/22/taking-screenshots-with-selenium/)
Thanks for support.
Rob
Is it possible to insert "brake point" in Sahi script to request a screenshot of browser window under test?
Similar solution was developed for Selenium (binil.wordpress.com/2006/12/22/taking-screenshots-with-selenium/)
Thanks for support.
Rob
Tagged:
Comments
I am not sure of your exact requirements but I remember there was a thread in the forum mentioning how we can use eclipse IDE to to create and execute sahi scripts. If you can configure it for sahi than I hope we can use the break point facility of the IDE wherever required.
Another quick fix that I can think of as of now (if u wanna take screenshots manually) is that put an alert statement just before where you want to take a screenshot. The script will halt there waiting for you to take action on the alert. You can drag the alert aside and take screen shot. A bit weired but it works!
Regards,
Pankaj
http://sahi.co.in/forums/viewtopic.php?id=1051
Thank you for your answer.
My requirement is to automate test and save screenshot images at crucial points during test execution for future evaluation by human.
Your suggestion about using alerts is really good, but would it be possible to call an external utility to take a screenshot at "brake point" inside the script?
Thanks
Rob
Use _execute() command to run some printscreen utility that can be run through commandline.
http://sahi.co.in/forums/viewtopic.php?id=888
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.
http://sahi.co.in/w/_setrecovery-recovering-from-a-scenario-without-try-catch
Ex.
_setRecovery(takeSnapShot);
will call this function whenever there is a failure or error.
Here it only worked with an 'error', not with an 'failure'.
I have only the textbox "name", I did the following:
It's an failure, but the recovery function wasn't called.
But when I do the following:
It calls the recovery function because it's an error.
Also, it doesn't work with the _continueOnError function? I don't want my script to be stoped.
I am using this function in my script.
function takeSnapShotNew($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($Filename+".png");
javax.imageio.ImageIO.write(image, "png", file);
_debug("after image io");
} catch (e) {
print(e);
}
}
When i run this function i get following error on sahi console,
Rhino lib:ReferenceError: "javax" is not defined.
It seem to go to catch after this line
javax.imageio.ImageIO.write(image, "png", file);
I am not sure why i am getting this. I worked with my dev team here and they tried placing rt.lib file in possible lib directory but in vain.
Thanks.
i capture like this:
1) download winshot
http://www.woodybells.com/winshot.html
2) 3)screen will be capture by winshot
javax not being found is mostly due to wrong version of Java. Check the output of
java -version
and add the correct Java to your PATH. That should mostly fix the issue.
Regards,
Narayan
I had a problem running one test at a time but I found the solution.
As I was using browser_types.xml and -threads didnt work as expected I did a little research and found capacity tag in the mentioned xml file.
Even though i am running my test in single thread , browser is getting minimized and not able to take screen shot of browser . Please suggest a way to keep my browser active (or how to maximize the window)
Regards,
Nithin
yes, im also facing same problem, when we minimize the browser it is not able to take screenshot of browser,
when we minimized it is capturing the desktop screenshot instead of browser
pls let us know, how to take screenshot of browser even when we minimized the browser
thanks in advance
Screen shot is working for me only in case if there is any failure in SAHI controller. Like script stopped due to some script. But in case if there is any assert is failing then in that case screen shot is not working.
here goes my code-
function takeSnapShot($ScrenShot){
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/$ScreenShot.png");
javax.imageio.ImageIO.write(image, "png", file);
} catch (e) {
System.out.print(""+e);
}
}
My screen shot function is working in case of failure not in error below is the script-
function takeSnapShot($ScrenShot){
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/$ScreenShot.png");
javax.imageio.ImageIO.write(image, "png", file);
} catch (e) {
System.out.print(""+e);
}
}
Error- in asserton fail case the function is not calling but moving forward to next step.
Failure- failure message in sahi controller and take the screen shot and execution also stop.
So my question is how can i take the screen shot in case of any assertion fails and how come once i saw a failure message on sahi it should move to next step for another transaction.
Please guide me.
Gyanadeep