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.
Query with <browser> tags
hi,
I've got some pre-2.0 scripts that I would like to update to get working with the latest release but I can't work out how to do it. An example of a simple function that is causing issues is:
I've got some pre-2.0 scripts that I would like to update to get working with the latest release but I can't work out how to do it. An example of a simple function that is causing issues is:
function logon($email, $password)
{
_setValue( _textbox("email"), $email);
_setValue( _password("password"), $password);
_click(_submit("Log On");
_assertEqual("Console Page", document.title, "Incorrect title on welcome page");
}
// from another file
_include('logon.sah')
_include('constants.sah') // logon and password variables are defined here
logon($logon, $password);
The code works fine from within the browser based controller but not from scripts. So I tried wrapping the function in <browser> tags, and calling it within the _call() function but the assert statement is causing an issue. The code becomes:<browser>
function logon($email, $password)
{
_setValue( _textbox("email"), $email);
_setValue( _password("password"), $password);
_click(_submit("Log On");
_assertEqual("Console Page", document.title, "Incorrect title on welcome page");
}
</browser>
// from another file
_include('logon.sah')
_include('constants.sah') // logon and password variables are defined here
_call(logon($logon, $password));
The error I get is -
"TypeError: 'null' is null or not an object
If I remove the assert statement then everything runs. Any advice?
Comments
If you have copy pasted the code from original one then theres a typo:
_click(_submit("Log On");
is missing the closing parenthesis. It should be:
_click(_submit("Log On"));
Rest we can say after looking at the error message.
Regards,
Pankaj.
What led me to do this was misdiagnosing another issue - my scripts, which work with the 20080627 release don't pass with the latest version. I assumed this was due to the new syntax but not so ....
The website I'm testing has menus that use JS to make them look like standard drop down application menus - e.g. you put your mouse over the top level menu and a drop down list of options appear. When I run the script it does not click on hidden menu options (e.g. _click("open") on the "file" menu) whereas it used to with the 2008 version of sahi. If I manually put my mouse over the top level menu when the script is running to expose the menu items ( "file" in this example) then it performs the click.
Any hint on how I can get sahi to click hidden JS elements?
Add _mouseOver(el) to bring up the menu.
Or
Add at the end of sahi/htdocs/spr/concat.js
I am going to add a property to sahi.properties to make this configurable and by default make it lenient on visibility. Sorry for the trouble.