18 January 2026:


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.

String comparios in sahi

RahulRahul Members
edited November -1 in Sahi - Open Source
Hi,

I am not getting how to do the string comparison in sahi.

I tried this if(a==b)
{some text
}


it is not working
Please any one let me know the procedure for string comparison in sahi

Thanks

Comments

  • Hello,

    Remember that you sahi variables precede the $ sign

    Example:

    if($parametro=="u"){
    some text
    }

    or

    Var $strU="u";
    if($parametro==$strU){
    some text
    }

    or

    if(_isVisible(_button("Aceptar"))){
    some text
    }

    Good Luck

    Oscar C (Facilos)
  • Hi Oscar C (Facilos),

    Thanks for your reply.

    I have tried all the scenario still it is not working.

    If ($(Current - 1 day) =="sun")
    {
    enter the loop and execute the script
    }

    Otherwise don't execute the script in Bracket.



    Please suggest other solutions
  • Hi Rahul,
    Can you add a _alert($(Current - 1 day)) just before your loop and check if the value of the variable is "sun".

    Regards,
    Tejas
  • Hi Tejas Thanks for your quick reply,

    Yes i tried that and it is displaying Sun on the browser alert box

    Regards,
    Rahul
  • hello,

    Could you be more clear in your condition to help.
    want to compare two dates?
    that is current?

    Thanks

    Facilos
  • Hi,

    No I am not comparing the date

    I wanted check the current date -1 is Sunday or not, if it is Sunday then i wanted to execute the script which is enclosed in the if statement(bracket) other wise I just wanted to execute the script which is outside if statement

    Thanks,
    Rahul
  • //With this code would enter the if {} when the current day is Monday.
    //Remember that the code of sahi is javascript
    
    var $date =new Date();//the current date
    var $day=(($date.getDay())-1);//the current day - 1 : Monday is 1, Tuesday 2.. Sunday is 0
    if ($day==0){//(1-1=0)
       _alert("Hi");//if $day is sunday, the message is Hi :) 
    }
    
    suerte

    Oscar.
  • Hi facilos.

    Thank you very much it is working

    Regards,
    Rahul
Sign In or Register to comment.