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.

How to handle alerts in sahi

madankumarmadankumar Members
edited January 2013 in Sahi - Open Source
Hi,

I am using sahi java code in eclipse, i have handle the alert window when mandatory fields are missed in the application

Best Answer

  • edited January 2013 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

  • how can i use assertEquals in sahi java code
  • Please use the following code:

    assertEquals("Alert for incorrect information", browser.lastAlert());

    --
    Kshitij
  • no, my doubt is assertEquals is not in sahi right, so if we write assetEquals() in my Eclipse class, its giving error
  • ya i got it, thanks
  • Thanks for you help Kshitij
  • Hi,
    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
  • Hi 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.
Sign In or Register to comment.