Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ sahipro.com with your query.

_prompt and _confirm not working

PachatPachat Members
edited 7:28PM in Sahi - Open Source
_prompt(message) and _confirm(message) described http://sahi.co.in/w/browser-action-apis
are not event parsed.

So we get a --FAILURE--

So I tried to add them to scheduler_functions.txt.
But then, it was impossible to navigateTo.

Is there a patch to get _prompt(message) and _confirm(message) working properly ?

Comments

  • narayannarayan Administrators
    Hi Pachat,

    You are right, _prompt and _confirm are not exposed as APIs by Sahi right now.

    Please have a look at this http://sahi.co.in/forums/viewtopic.php?id=2038 to see how _prompt can be used.

    _confirm is similar.

    Regards,
    Narayan
  • narayan,

    It works !

    I gave a little enhancement, allowing to custumize the message
    <browser>
    function promptForUserInput(message){
        _sahi_temp_promptValue = _sahi._prompt(message);
    }
    </browser>
    
    function getUserInput($message){
        var $value = null;
        _call(promptForUserInput($message));
        _set($value, _sahi_temp_promptValue);
        return $value;
    }
    
    
    // Get the user input in your script
    var $userInput = getUserInput('Enter a name');
    _alert($userInput);
    

    Thank you for your support
  • narayan wrote:
    _confirm is similar.
    Regards,
    Narayan

    In fact, for some reasons, it looks like not to be quite similar.
    The following code does not work
    <browser>
    function confirmForUserInput(message){
        _sahi_temp_confirmValue = _sahi._confirm(message);
    }
    </browser>
    
    function confirm($message){
        var $value = null;
        _call(confirmForUserInput($message));
       //Firebug says :  _sahi_temp_confirmValue is not defined
        _set($value, _sahi_temp_confirmValue);
    
        return $value;
    }
    
    
    // Get the user input in your script
    var $userInput = confirm('Are you sure ?');
    _alert($userInput);
    
    What am I doing wrong ?
  • narayannarayan Administrators
    Hi Pachat,

    _confirm function was not defined on Sahi. Use the code below:
    <browser>
    function confirmForUserInput(message){
        _sahi_temp_confirmValue = _sahi._confirm(message);
    }
    Sahi.prototype._confirm = function (s) {
        return this.callFunction(this.real_confirm, window, s);
    };
    </browser>
    
    function getConfirmResult($message){
        var $value = null;
        _call(confirmForUserInput($message));
       //Firebug says :  _sahi_temp_confirmValue is not defined
        _set($value, _sahi_temp_confirmValue);
    
        return $value;
    }
    
    
    // Get the user input in your script
    var $userInput = getConfirmResult('Are you sure ?');
    _alert($userInput);
    

    Note that I am using getConfirmResult instead of confirm. If not, any javascript code calling confirm() will invoke this function, instead of Sahi's mock confirm function.

    Regards,
    Narayan
  • Great! It works fine.

    Thanks
This discussion has been closed.