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.

input popup possible?

vt_hokie2008vt_hokie2008 Members
edited November -1 in Sahi - Open Source
I would like to have my script start by giving the person running the script a popup asking for things like username and password, then pass those answers back into the script to be variables. Is this possible in Sahi?

Comments

  • I guess you could use a javascript prompt()...

    var $name=prompt("Please enter your name","John Smith");
    document.write("Hello " + $name);
  • TheeranTheeran Members
    edited October 2011
    Hi dasspunk,

    why to use javascript prompt(),Sahi has it own API _prompt to perform such functionalities.you can use the following script to get popup for username and password and use it as variables into script.
    var $a=_prompt("Enter the username");
    var $b=_prompt("Enter the password");
    _alert("The username is"+$a);
    _alert("The password is"+$b);
    

    This might help you.

    Regards
    Theeran.
  • Theeran wrote:
    Hi dasspunk,

    why to use javascript prompt(),Sahi has it own API _prompt to perform such functionalities.you can use the following script to get popup for username and password and use it as variables into script.
    var $a=_prompt("Enter the username");
    var $b=_prompt("Enter the password");
    _alert("The username is"+$a);
    _alert("The password is"+$b);
    

    This might help you.

    Regards
    Theeran.

    Thanks! Only problem here is a & b are returned as null.
  • vt_hokie2008vt_hokie2008 Members
    edited October 2011
    Here's what I came up with that works pretty well so far
    $usernamePhrase="Enter a username";
    $passwordPhrase="Enter a password";
    <browser>
    function promptForUserInput($phrase){
        promptValue = _prompt($phrase);
    }
    </browser>
    function getUserInput($phrase){
        var $value = null; 
        _call(promptForUserInput($phrase));
        _set($value, promptValue);
        return $value;
    }
    var $username = getUserInput($usernamePhrase);
    var $password = getUserInput($passwordPhrase);
    
  • One question left though: how can I change the default text that appears in the prompt textbox? It shows "undefined" in the text box and _prompt($phrase, "text"); doesn't do it
Sign In or Register to comment.