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.
Comparing the dates
Hi,
We have a functionality where we need to compare two dates, which are in different format.
EX: date1 : 27/Jun/2011 , date2 : 28-Jun-2011.
Also date2 is always the next day of the date1. Is there any predefined function for dates in sahi or any way we can compare these two dates because we need to keep in mind that if we try to increment the day then 28 days in Feb, 30, 31 needs to be taken care and it has to go to next month rather than just 31,32 incrementation.
Kindly help us with this.
Regards,
Bhavitha
We have a functionality where we need to compare two dates, which are in different format.
EX: date1 : 27/Jun/2011 , date2 : 28-Jun-2011.
Also date2 is always the next day of the date1. Is there any predefined function for dates in sahi or any way we can compare these two dates because we need to keep in mind that if we try to increment the day then 28 days in Feb, 30, 31 needs to be taken care and it has to go to next month rather than just 31,32 incrementation.
Kindly help us with this.
Regards,
Bhavitha
Comments
What type of comparison do you want? Do you want to check if
date2: 28-Jun-2011 = date1:27/Jun/2011 + 1 ?
If so, then you can use the JavaScript date object. Convert the strings to a date and then perform a date operation on them.
Refer : http://programming.top54u.com/post/Javascript-Convert-String-to-Date.aspx to convert a string to date.
Regards
Sumitra
Some how I could not create New Post, Hence I am posting my query here as this is something similar to my problem.
Is there any function available in SAHI to compare two Strings?
For the first question I got quick reply from you, later I was not getting any response. Apologies If I am posting silly questions, however, these are very crucial for me to go ahead as I am new to SAHI.
Thanks in Advance.
Regards
Laxshmi
Can you please be more specific about your issue?
If you are trying to compare two strings which are equal then you can use:
_assertEqual(expected, actual, message);
For more information:
http://sahi.co.in/w/_assertequal
Regards
Sumitra
Many thanks for your response.
In a loop I am comparing 2 strings, if the 2 strings are same I would like to exit from the loop and do the further action.
So How Can I exit from the loop if assertion failed? That was my query.
Can you please suggest?
Regards
Laxshmi
You can use break.
The break statement will break the loop and continue executing the code that follows after the loop (if any).
Eg:
if ($string1==$string2){
break;
}
Check if this solves your issue.
Regards
Sumitra
_assertNotEqual($item2, $rs_user_Profile[$i]["KeyPage"], "Actual Value")
If above assertion fails, it should come out of loop. Is there any way we can do this?
Regards
Laxshmi
Use:
if ($item2==$rs_user_Profile[$i]["KeyPage"]){
break;
}
Regards
Sumitra
However, I would like know whether we can validate Assert results?
An assertion basically checks for a condition, and throws an exception if the condition is false.
For more information check :
http://sahi.co.in/forums/viewtopic.php?id=2250
http://sahi.co.in/w/all-apis
Regards
Sumitra