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.

How to use an empty String ?

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

I have a String in my program that is setable by the user. I'd like to do a specific action if this string is empty, but how do I use it ?

$string = "192.168.155.4"; // this is setable by the user

if(_condition( $string != null)){
_click(_link(...));
}

So, if $string exists I want to do some specific action...And if it soesn't exist, I want to do nothing. But I dunno how to use the fact that the string is empty . Is it with " " or 'null' or 'undefined' ? And how the user lust set $string to make possible the use of the emptiness..

Any ideas ?
:)

Comments

  • Hi,

    An empty string means "".
    i.e $string = "";
    If you talk about a string that does not exist, it is undefined.

    Regards,
    Pankaj.
  • Ok, so :
    var $ip2start="";
    
    for($i=0; $i<5; $i++){
    
      if(_condition($ip2start == "")){
        $k = _random ( 253 ) + 1;
        $ipaddress2[$i] = $ip2start + $k;
      }
    
    }
    
    should work...?

    ( don't pay attention to the meaning of the code, it's a snippet of a bigger one and it does not have meanings ...!)
  • Hi,

    This should work :)

    Pankaj.
  • Yes but it doesn't ...

    _saveCondition("" == "");
    _saveCondition("" == "");
    _saveCondition("" == "");
    _saveCondition("" == "");

    ... :)
  • Hi,

    Check the source code of your application and see what is the value of $ip2start when the string is empty.
    It may be the case that when it has no value it may not be present in the code at all. in that case you will have to use null in place of "".

    Regards,
    Pankaj.
Sign In or Register to comment.