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.

Need some help with window popup

Lou10120Lou10120 Members
edited November -1 in Sahi - Open Source
Hello,

Could anybody please tell me how does Sahi recognise the windows popup (i mean the windows alert) ?


Here is my purpose :
When i try to log in a web page, i must provide the login and password, then click on the "Validate" button. If i enter a wrong login or password, an alert (windows popup) is displayed with the message "The login/password is incorrect", but it seems that Sahi does not handle this popup.

Could anybody help me please ?

Thanks !!!

Lou10120

Comments

  • Hi,

    I also am facing a similar problem. I need to click "OK" or "Cancel" button in the Windows Internet Explorer alert.
    Anybody having a solution or atleast a pointer in which direction should i proceed to resolve the problem is welcome.

    Regards,
    Pankaj.
  • narayannarayan Administrators
    Have a look at _expectConfirm (http://sahi.co.in/w/_expectconfirm)
  • Hi,

    Thanks for the quick response Sir. I have tried it but in vain. I wonder if I am using "_expectConfirm()" in a right way and in a right situation.
    I tried to evaluate this simple expression

    confirm("hi");
    _expectConfirm("hi", false);

    but nothing happened. Please suggest if i am using it in a wrong way.

    Thanks,
    Pankaj.
  • diikeediikee Members
    that makes 3 of us facing a similar issue

    I am still waiting on a build which should address the issue with window "Save As" prompt where it doesn't know how well to handle that.
  • narayannarayan Administrators
    diikee,
    These are not related issues.

    javascript alerts, confirms and prompts are handled well by Sahi.
    When a button is clicked and a confirm box appears, Sahi silently acts as if "OK" was clicked on that dialog, without showing that dialog.
    If you need to have the behavior of a "Cancel" instead of an "OK", use an _expectConfirm("message on the confirmation dialog", false) before the _click line.

    So if
    _click(_button("Login"));
    
    was going to throw that confirm dialog,

    use
    _expectConfirm("Are you sure", false); // false works as cancel
    _click(_button("Login"));
    
    I guess you will get your "Save As" on Monday. (Recent studies show that a nice donation to Sahi makes response times much faster)
  • diikeediikee Members
    narayan,

    _expectConfirm("default values.Do you want to continue?", true)
    _popup("Image settings")._click(_link("factory defaults"));

    this causes the script to stop playback, I comment it out and it works fine.
    I believe the _expectConfirm is still buggy in a way.

    "Donations are meant to be willfully"
  • narayannarayan Administrators
    Hi diikee

    _expectConfirm relates to window.confirm
    Save As relates to links which have a content-type other than what a browser can render.
    _popup() relates to new windows opened through window.open() or through html.

    Let us attack one problem at a time, in different topics. Otherwise, it would be tough for us to figure out what exactly is going wrong.
    It takes the focus away from what the initial posters had intended.

    Could you please elaborate on the problem of how _expectConfirm stops play back? It kind of feels like it is a combination of _expectConfirm and having multiple popup windows. More information would be helpful.

    Regards,
    Narayan
  • Hi Narayan,

    The "_expectConfirm" is working fine. I must have been calling it in a wrong way.
    :)


    Thanks and Regards,
    Pankaj.
  • diikeediikee Members
    _click(_link("motion"));
    _setSelected(_select("whichBox"), "1");
    _expectConfirm("This will set all motion detection settings to factory default values.
    Do you want to continue?", true)
    _click(_link("default"));

    this causes the playback of the script to error with
    "Playback Stopped" Success

    if I comment out the _expectConfirm statement, everything is okay
  • narayannarayan Administrators
    Just confirming, is the string in _expectConfirm broken into two lines?
    If yes, use
    _expectConfirm("This will set all motion detection settings to factory default values.\nDo you want to continue?", true)
    
  • diikeediikee Members
    Narayan,

    thanks...the string was broken into multiple lines...

    it works okay now.
  • Naranayan,

    i always get a successful playback even if the expectConfirm text does not match with the text found in the window. Is this right?? or am I using the wrong function. when u referred to the javascript, it seems that the window prompt is an alert(); -- should i used either _expectPrompt(text,value); or _expectConfirm(text,value);


    here's my code:

    _expectConfirm("Invalid weeeeeehhhh!!!! You should enter the correct one", true);

    the text in the window is "Invalid Password! You should enter the correct one"

    Thanks,
    =tinchie=
  • any updates on this?? thanks!
Sign In or Register to comment.