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.
Wrapping assert calls
Operating System: Windows 7
Browser: Google Chrome 16.0.912.63 & IE 8
Sahi Build: V3.5 (2011-07-19)
Hello,
As my first post here I would like to say that SAHI is a nice product and we are about to use it for automation of several test suites for several products.
The question I have is regarding the creation of a function that calls multiple asserts. It can be seen as a wrapper: instead of writing 4 lines of code, I can write 1 line of code which does the same.
Here is the code that I tried, but which does not work:
When I call 'AssertText(_div("username"), "username");' the SAHI playback tool shows '_assertExists(element)', instead of '_assertExists(_div("username"))'. Ofcourse it fails, because it does not recognize 'element'.
The problem is probably my lack of Javascript knowledge. I have Googled for solutions and for the possibility of C-style macro definitions in Java, however I have found nothing.
Do you guys have any ideas on this problems?
Regards,
Dave
Browser: Google Chrome 16.0.912.63 & IE 8
Sahi Build: V3.5 (2011-07-19)
Hello,
As my first post here I would like to say that SAHI is a nice product and we are about to use it for automation of several test suites for several products.
The question I have is regarding the creation of a function that calls multiple asserts. It can be seen as a wrapper: instead of writing 4 lines of code, I can write 1 line of code which does the same.
Here is the code that I tried, but which does not work:
function AssertText(element, text)
{
_assertExists(element);
_assert(_isVisible(element));
_assertEqual(text, _getText(element));
_assertContainsText(text, element);
}
When I call 'AssertText(_div("username"), "username");' the SAHI playback tool shows '_assertExists(element)', instead of '_assertExists(_div("username"))'. Ofcourse it fails, because it does not recognize 'element'.
The problem is probably my lack of Javascript knowledge. I have Googled for solutions and for the possibility of C-style macro definitions in Java, however I have found nothing.
Do you guys have any ideas on this problems?
Regards,
Dave
This discussion has been closed.
Comments
The code should be:
Now call the function using:
AssertText(_div("username"), "username");
Regards
Sumitra