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.

block unwanted javascript function on a web page

svargiusvargiu Members
edited November -1 in Sahi - Open Source
I have an application that call a win.close() function and stops the test until the page is close.
Is there some way to block unwanted javascript call or code with sahi?

Comments

  • narayannarayan Administrators
    If you know which function it is, just add a blank function of the same name.

    For example, if closeWindow() is the javascript function causing this, just add
    _call(closeWindow = function(){});
    
    in your script. This will overwrite the already loaded function. You will have to add this to your script such that this call happens once you are on that page.

    Another way to do it is to add a blank function definition at the end in sahi/htdocs/spr/playback.js
    eg.
    closeWindow = function(){};
    
  • svargiusvargiu Members
    Hi Narayan,
    thanks for your reply , I have found the problem with your hint : the function launched is a window.opener.close() integrated in a javascript.The javascript create a form that launch an url with parameters and close itself in a wrong way.
    If the buggy javascript in the browser is called TEST with sahi have I chance to replace it with a self made TEST javascript in the sahi script ?
Sign In or Register to comment.