Comparison between 2 values always returns false when I expect true

Hi all,
I’m trying to automate a test case but I ran into a problem.
The first thing I do in my sequence is to crate a variable
currentTime=Now.ToString(“MM-dd-yyyy_hh_mm_ss”)

I use this as a timestamp and put it in an email body. Later I open the application I use and read the email body from there using a get text activity with output a new variable called emailBody.
Then I make an If statement, which is emailBody=currentTime
And I have write line activities for then and else. It goes to else every time and I don’t understand why. I use a write line activity for both variables and they look the same to me, at least the text looks the same. Both are declared as strings and the scope is the whole sequence. Any ideas what might be causing that?

Hi, please send screens of variables to comparision in Debug Mode.
You may have white space in your text.

1 Like

@elitsa.kerefeyska

Can you try emailBody.trim.equals(currentTime.Trim)?

Regards
AN

That worked like a charm, thank you so much!

Welcome :+1:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.