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.

Assert on the text of alert Pop up message

1701198117011981 Members
edited November -1 in Sahi - Open Source
Hi all members...

My problem is :

On the login page, two fields "username" and "password"...both these fields are mandatory

Now if user enters only password and does not enter the username field and click submit button...then alert message popup window opens as "Username required"

I need to put an assert on the text of this alert message "Username required"....

How can i achieve this...please provide a solution for this one

Comments

  • Hi,

    If its a confirmation dialog box with "OK" and "Cancel" buttons then you can use _expectConfirm("textString", true) (true will click "OK", change it to false in case you want to cancel it). It takes two arguments. The first one being the text string that appears in the dialog box. It will automatically validate for the presence of the text string if it runs successfully.
    Also see http://sahi.co.in/forums/viewtopic.php?id=107

    Regards,
    Pankaj.
  • 1701198117011981 Members
    edited February 2009
    Hi pankaj,

    Thanks for the prompt reply !!!!!!!!

    But this solution doesnt seems to be clicking for me...as the reason is...

    In my Microsoft Internet Explorer window (alert message window), there is only just one button "OK"...

    Can i still use the _expectConfirm function ????

    I think "No" as the syntax of this function is true (for OK button) and false (for Cancel) button

    One more thing...

    When i used this function, even if i changed the text of alert message (say my alert msg is : "Please select Expense Type." and i changed it to "Do not try this")...this script still passess...whereas it should be failed, as the two labels are now different...

    Please suggest another solution ASAP...

    Thanks...
  • narayannarayan Administrators
    Have a look at this: http://sahi.co.in/w/_lastalert
  • Narayan,

    This applies to my alerts not displaying (during record or playback. right?). Could we have an option in sahi_properties that allows alerts to display (in automating a demo to show how invalid data is handled, for example.)

    Thanks,
    RR
Sign In or Register to comment.