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 ignore Upper or Lower case in assertion?
I was doing assert for a content and the content is sometimes changing only lowercase letters to uppercase letters and vice versa. Script is failing just because of the change in case. I don't want to fail it for the small things. I was wondering whether there is any ignoreCase API in Sahi. I have searched through the forums but couldn't find it. I would really appreciate if someone can guide me through this issue. Thanks in advance.
Best Answer
-
Hi tsiva,
I can try and provide you with a workaround.
Use the following code with the modifications as per your requirement.
This would make the assertions not fail based on case.var $contents = _getValue(_textbox("your_content_getter"); var $contents_in_lowercase = _getValue(_textbox("your_content_getter").toLowerCase(); _assertEqual("your_content_in_lowercase", $contents_in_lowercase);
Regards.
Answers
var $contents = _getValue(_paragraph("welcome_info"));
var $contents_in_lowercase = _getValue(_paragraph("welcome_info").toLowerCase());
_assertEqual("Welcome to Vehicle Acquisition The VA application is xyz proprietary tool designed to increase productivity and ensure the highest standard of excellence for the VA department.". $contents_in_lowercase);
I got the beow error after replaying the script:
_sahi.setServerVar('___lastValue___1377275854592', _getValue(_paragraph("welcome_info").toLowerCase()));
TypeError: _sahi._paragraph(...).toLowerCase is not a function
http://lpusamqapp01:9080/_s_/spr/concat.js:3480
Sahi.prototype.ex@http://lpusamqapp01:9080/_s_/spr/concat.js:3480
http://lpusamqapp01:9080/_s_/spr/concat.js:3267
What version of Sahi OS are you using?
Regards.
2013-04-29
It says _sahi._paragraph(...).toLowerCase() is not a function. This is because i made a small mistake in the above script.
Please replace the following line:
with this line:
Now it should work for you.
Regards.
Its failing because of mismatch. The code is not really ignoring the changed case in a word. Please check the below error message. Failed the assertion because of the lower case conversion. My only the requirement is ignoring case from a sentense..not converting to lower case. Could you research for a workaround for me? Thanks for your help
Expected:"Welcome To VA The VA application is xxx USAs proprietary tool designed to increase productivity and ensure the highest standard of excellence for the VA department."
Actual:"welcome to va the va application is xxx usas proprietary tool designed to increase productivity and ensure the highest standard of excellence for the va department."
If you want the the test case should pass despite difference in case, you can change both the expected and actual text to lowercase/uppercase WHILE ASSERTING.ie.
Let $expected be your expected text and $actual be the actual text you're getting.
If you put your _assertEqual statement in the following manner:
it is basically ignoring the case and passing the test as you need. I mean to say that you shouldn't change the value of $expected or $actual but simply assert on their lowercase values.
Regards.
Thanks for your quick response and workaround solution but that's not my requirement was. Don't worry for now.