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.

Batch mode needs someone to click in a button

JaoBrJaoBr Members
edited November -1 in Sahi - Open Source
Hi Narayan.

Everytime that I run my scripts in batch mode I need to click in the button "No":

scrng.jpg

Translation:
The Web page that you are visiting is trying to close the window.

Do you want to close the window?

Yes No

It's required by the system that the user makes login. When it happens with the Sahi Controller, this dialog doesn't comes up, neither when someone access the system. But when the test is running through batch mode the dialog comes up, and if I click in the "Yes" button the test fails.
Is there anyway to make this without needing someone to click in the button?

Comments

  • narayannarayan Administrators
    Is this how your workflow is?
    Page 1 opens Page 2 and Page 1 is closed, either by Page 1 or Page 2
  • JaoBrJaoBr Members
    No, Page 1 opens Page 2, but Page 1 isn't closed.
  • narayannarayan Administrators
    Then who is trying to close the window?! Is there any code which attempts to close any window?
  • JaoBrJaoBr Members
    That's the question.
    When I run the script by the Sahi Controller, the main window isn't closed, neither when someone is using the system this happens.
    Only when I run scripts in batch mode something try to close the window.
  • JaoBrJaoBr Members
    Hi Narayan, no idea? :(
  • narayannarayan Administrators
    This message comes when you have a window.close() in your script. Can you do this:

    1) Create a test with just a couple of steps navigating from one link to another in your application
    2) Add just that single test in your suite file and run the suite. Make sure that your start URL in the batch file/ant target is correct.
    3) Check if the error still occurs, and if yes, email the script, suite file, log file and batch file/ant target to support@sahi.co.in . We will have a look at it and let you know.

    One other work around, is to press tab and then space using java.awt.Robot to simulate clicking on "no". You can add the code below to your script, at the place it throws the prompt.
    var robot = new java.awt.Robot(); 
    function keypressNative(key){
        robot.keyPress(key);
        robot.keyRelease(key);    
    }
    
    keypressNative(java.awt.event.KeyEvent.VK_TAB);
    keypressNative(java.awt.event.KeyEvent.VK_ENTER);
    

    This will work only if the window is in focus, so this is not a recommended solution.

    Regards,
    Narayan
  • JaoBrJaoBr Members
    Hi.

    It didn't work and yes, I have a window.close here, but it only executes when already exists a window with the same name, but they are all closed before the execution of the suite.

    I will email you soon, thanks.
Sign In or Register to comment.