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.

[Help] Sahi doesn't handle lanuched-dialog (through *.sah)

wei_changwei_chang Members
edited September 2013 in Sahi - Open Source
Hi Seniors:
Sahi(open) v4.4

I met a problem that about sahi hasn't handled buttons on launched-dialog to move forward.
As following as few links to share you my situation.
https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-prn2/1268176_571155039613473_614320228_o.jpg
picture1,
my purpose was to _link those three links and steps as Troubleshooting>>Restore/Reboot>>REBOOT

https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-frc3/1265261_571155072946803_852440744_o.jpg
picture2,
So, when _click _link("Reboot"), it was launching a dialog and inquired 'OK' or 'Cancel' buttons.
(In case, I want to click 'Cancel')
meanwhile, I very sure to (used Sahi controller) _click(_button(" Cancel")); was working.
Therefore, I appended _click(_button(" Cancel")); to test.sah (for run by batch).

https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-ash4/1044703_571155042946806_2084406242_n.jpg
picture3,
I used testrunner.bat to run test.sah, the result was unexpected and on log it revealed "_click was not found...etc"

Even I tried IE and Chrome those were failure.
are there somebody ever experienced that?
Please help me, thanks

BR
Wei

Answers

  • Hi Wei Chang,
    By default, Sahi doesn't show the confirm/alert boxes and goes ahead taking "OK" as the default response.
    So in this case, you need to add the following statement before your click statement that launches the confirm box:
    _expectConfirm("<message_on_your_confirm_box>", false);
    

    You can have a look at how this API works on the following link:
    http://sahi.co.in/w/_expectConfirm
    

    Let me know if you still have some problem.

    Regards.
  • wei_changwei_chang Members
    edited September 2013
    Hi Pratyush_Tyto,
    Thanks for replying,
    By default, Sahi doesn't show the confirm/alert boxes and goes ahead taking "OK" as the default response.
    << I knew this, but my problem is very tricky in case, here I have two stranges:
    1. As following picture, why it could hover and brought up '_button(" Cancel ");' seemingly it alike a double page. normally, (my experience)confirm-dialog seems not working directly with Sahi controller. (right?)
    https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-frc3/1265261_571155072946803_852440744_o.jpg

    2. I tried several patterns as like:
    a) _expectConfirm("If a voice call is in-progress, it will disconnect with reboot. Do you want to continue?", true); (I hope it can as I expected to accept 'OK' for certainly reboot, unfortunately, it wouldn't.)
    b) As I know by default it will automate returning 'OK', so I tried another to ignore above '_expectConfirm(xxxx, true)', observated it and wouldn't be reboot, guessed so it might not return 'OK'.
    https://fbcdn-sphotos-f-a.akamaihd.net/hphotos-ak-ash4/1269021_571564556239188_581147032_o.jpg

    Re-present my emphasis, seems something wrong to handle this kind of dialog in 'OK' and 'Cancel' button.

    Please help me if you got any ideas.
    BR
    Wei
  • hi wel_chang,
    First of all i would like to remind you that _expectConfirm should be given before your action (say _click(button). And the other thing is you need to use "false" in place of "true". Then do whatever action you want to do on the confirmation/alert window. This should work for a confirmation window that has more than one button. Please let me know if that doesn't work. I have successfully used in multiple situations with _expectConfirm(). Please provide your code here for the confirmation window close, i can modify that for you to work. Let me know how that goes.
  • Hi wei_chang,
    Please try this and let me know if it works?
    _expectConfirm("If a voice call is in-progress, it will disconnect with reboot. Do you want to continue?", false);
    _click(_button("Test"));
    _click(_button("cancel"));
    I fyou want to click OK button change the cancel to OK.
  • Hi tsiva,
    Sorry for late,
    I'll plan to try as you suggest later.

    Thanks
    BR
    Wei
  • wei_changwei_chang Members
    edited October 2013
    Hi Tsiva,
    I did trying of you suggested,
    that still could not click down button, and showed errors in logs after playback,

    [a few part of my script]
    _expectConfirm("If a voice call is in-progress, it will disconnect with reboot. Do you want to continue?", false);
    _click(_button(" OK "));

    [\userdata\logs\playback\..]
    Starting script
    _setValue(_textbox("user"), "admin") [110 ms] [01:00:28.671]
    _setValue(_password("password"), "password") [157 ms] [01:00:28.828]
    _click(_submit("Login")) [109 ms] [01:00:28.937]
    _click(_link("Restore/Reboot")) [2844 ms] [01:00:31.781]
    _click(_link("Reboot")) [1797 ms] [01:00:33.578]
    _expectConfirm("If a voice call is in-progress, it will disconnect with reboot. Do you want to continue?", false) [140 ms] [01:00:33.718]
    _click(_button("\ufffdOK\ufffd")) Error: The parameter passed to _click was not found on the browser [0 ms] [01:00:44.000]
    Stopping script

    As following of captured screen was being stuck where it didn't go to _click(_button(" OK "));
    https://fbcdn-sphotos-g-a.akamaihd.net/hphotos-ak-ash3/1004998_589575794438064_634271928_n.jpg

    On the contrary, it worked well when through sahi-controller to set,
    meant that as same as command "_click(_button(" OK "));", to put it at sahi-controller, that could make clicking ok button.

    BR
    Wei
  • HI wei_chang,
    From your code, my understanding was that the confirm message pops up after clicking the Reboot link. If that's correct then your _expectConfirm should be before the _click(_link("Reboot")). It seems you are using the _expectConfirm() after _click(_link("Reboot")). Actually it should be before the _click(_link("Reboot")). Please try the below code and let me know if that works for you.

    _setValue(_textbox("user"), "admin");
    _setValue(_password("password"), "password");
    _click(_submit("Login"));
    _click(_link("Restore/Reboot"));
    _expectConfirm("If a voice call is in-progress, it will disconnect with reboot. Do you want to continue?", false);
    _click(_link("Reboot"));
    _click(_button("\ufffdOK\ufffd"));
  • Hi tsiva,
    Sorry for late,
    I will plan to try it as your tips ASAP.

    BR
    Wei
  • Hi Tsiva,
    Issue resolved in some helps,

    In case, to gave
    _click(_button("/OK/"));
    to put "/" instead of spaces.
    FYI
    (Please close this)

    Thanks
    BR
    Wei
  • Hi Wei,
    I will be closing this ticket.

    Regards.
This discussion has been closed.