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.
Clear _lastAlert()
Is there a way to clear the _lastAlert() buffer?
My test case:
A form requires First Name and Last Name input fields.
1) Submit without filling in these two required fields, verify that _lastAlert() == "missing required fields"
2) Fill in required fields, submit; verify _lastAlert() != "missing required fields"
Instead of _assertNotEqual, if the Submit button takes me to profile.php, I test for the existance of _spandiv("Thank you for registering, Kevin Kole..."); in other words, checking that the page after the form is correct instead of the checking for the absence of the alert message. But, I would still like to find out if it's possible to clear the _lastAlert() buffer.
My test case:
A form requires First Name and Last Name input fields.
1) Submit without filling in these two required fields, verify that _lastAlert() == "missing required fields"
2) Fill in required fields, submit; verify _lastAlert() != "missing required fields"
_navigateTo("myform.php");
_click(_submit("Submit")); // Did not fill in required fields, assertion should pass
_assertEqual(_lastAlert(), "missing required fields");
_setValue(_textbox("FirstName"), "Kevin");
_setValue(_textbox("LastName"), "Kole");
_click(_submit("Submit")); // Required fields are filled in, assertion should pass
_assertNotEqual(_lastAlert(), "missing required fields"); // PROBLEM: _lastAlert() does not get cleared.
Workaround:Instead of _assertNotEqual, if the Submit button takes me to profile.php, I test for the existance of _spandiv("Thank you for registering, Kevin Kole..."); in other words, checking that the page after the form is correct instead of the checking for the absence of the alert message. But, I would still like to find out if it's possible to clear the _lastAlert() buffer.
Comments
Meanwhile you can use this hack: