18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
how to append a variable to a static string ?
I am logging into an application using username and password. I am using a function for the login by declaring variable for the username and password. After successful login i need to verify mouse over action on a string ("Welcome +username"). I was able to login successfully but failing when the mouseover action is done. There was no error If i don't use a variable. Here is the error that i was getting.
_setValue(_textbox("j_username"), $test);
_setValue(_password("j_password"), "password");
_click(_imageSubmitButton("loginbtn.gif"));
_mouseOver(_cell((Welcome, "test")));
--Stopped Playback: FAILURE--
Here is the sahi code that i have written for the above function
$usrname="test";
$pasword="password";
function login($usrname, $pasword)
{
_setValue(_textbox("j_username"), $usrname);
_setValue(_password("j_password"), $pasword);
_click(_imageSubmitButton("loginbtn.gif"));
}
login($usrname,$pasword);
_mouseOver(_cell((Welcome, $usrname)));
_setValue(_textbox("j_username"), $test);
_setValue(_password("j_password"), "password");
_click(_imageSubmitButton("loginbtn.gif"));
_mouseOver(_cell((Welcome, "test")));
--Stopped Playback: FAILURE--
Here is the sahi code that i have written for the above function
$usrname="test";
$pasword="password";
function login($usrname, $pasword)
{
_setValue(_textbox("j_username"), $usrname);
_setValue(_password("j_password"), $pasword);
_click(_imageSubmitButton("loginbtn.gif"));
}
login($usrname,$pasword);
_mouseOver(_cell((Welcome, $usrname)));
This discussion has been closed.
Comments
You can use it like
_mouseOver(_cell(("Welcome, "+$usrname)));
OR
var $str = "Welcome, "+$usrname;
_mouseOver(_cell($str ));
_mouseOver(_cell("Welcome,"+"test"));
Error: The parameter passed to _mouseOver was not found on the browser at Oct 21, 2011 11:07:42 AM
The quotes around the variable name is taking when adding the name to the Welcome message and hence its throwing the error. The actual value supposed to be Welcome, Test (no quotes around the message).The quotes should not be there. How can i do that? I have to give the quotes when assigning a string to the variable. Please advise me.
Use
"Welcome, "+$usrname
not
"Welcome,"+$usrname