Compare Two String or Variables

Hi Guyz,

I need help on following thing, see am taking two outputs from webpage using get attribute “aaname” and storing the values in variables. Now I need to check if two variables are same I need write into excel one value or two variables or not matching then I write into excel some other value.

For Ex: AA001 = AA001 THEN my output on excel is AA001
AA001 = THIS IS INCORRECT THEN my output on excel is error (or) blank

it’s possible to achieve in if statement or any other. Please guide me. Thank you.

Gokul.

Hello Gokul,

I’ve made two variables as String as below.

String firstString = “AA001”;
String secondString = “AA001”; // with same value
// am comparing them using if condition
if(firstString.equals(secondString)){
// then write AA001 into excel or
}else{
// don’t write anytime
}

please let me know. once it’s success.

Thanks,
Pankaj

3 Likes

Hi @gokulvasant,

yes you can achieve using if condition itself.

you can try this code

Regards,
Arivu

4 Likes

@arivu96 and @Pankaj.Patil

Thanks a lottttttt…

It’s working :slight_smile:

Hi… one more thing guyz,

how can we remove “/” in a string for ex: string = “20/12/1955” I need “20121955”.

Please help me out thanks a lot once again.

1 Like

Hi @gokulvasant,

strValue=strValue.Replace("/","")

Regards,
Arivu

3 Likes

Hi…

Thanks a lot.

Good to hear :slight_smile: