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.
How to handle alerts in sahi
Hi,
I am using sahi java code in eclipse, i have handle the alert window when mandatory fields are missed in the application
I am using sahi java code in eclipse, i have handle the alert window when mandatory fields are missed in the application
Best Answer
-
Hi,
Sahi does not display alerts during playback.
But the content of the alert is made available so that assertions can be made on it.
You can use _lastAlert() API: Returns a string with the value of the last occured alert.
e.g.
After clicking on Save button, you can use the _lastAlert:
_assertEqual("Alert for incorrect information", _lastAlert());
With java driver you can use lastAlert() ;
--
Kshitij Gupta

Answers
assertEquals("Alert for incorrect information", browser.lastAlert());
--
Kshitij
I need to handle Alerts in Sahi Java code in Eclipse
i want to click on Ok button present in alert. the Alert is not Visible
So please Help me with Sahi Java code to click on ok button of Alert so that my Code runs properly
thanks,
satish
Sahi automatically handles alerts and doesn't show them. You wont need to click on 'Ok'.
If you need to get the last alert message, you need to use the lastAlert() API.
Regards.