stuck at the beginning: how to compare text?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
schrauber
Newbie
Posts: 2
Joined: Wed Jul 22, 2015 11:55 am

stuck at the beginning: how to compare text?

Post by schrauber » Wed Jul 22, 2015 12:04 pm

Hi all,

first, my name is Thomas (or Tom for short) and I just started with macro sheduler. Normally I do manual tests, so now I am searching for a software to do automated GUI tests. So here I am, testing macro sheduler :).

I have to say that I am an absolute newbie when it comes to programming or coding.

I will check the panels and labels in the GUI of correct wording, and later on I will check the translation too.

Code: Select all

Let>logfile=C:\Users\admin\Documents\testresults.log
GetTextInit
GetTextInRect>409,53,467,65,result
if>result={"TEXT"}
    TimeStamp>logfile, wording:Success
Elseif
    TimeStamp>logfile, wording:Failed
Endif
my idea is, to compare if the value from GetTextinRect has the correct text in it. If the text is "TEXT", the result is success, if not, it is failed. But it will not work.

When I use if>result= then the test failes, if I use if>result<> then the test will be successfull, even if the text in the panel ist not "TEXT". When I use "TEX" the test will still be successfull.

Hope you understand what I mean (sorry, I'm german, english is not my native language) and are able to give me a hint :)
And by the way, I already spend 2hrs in reading in this forum, but did not find the answer myself.


Thanks!

Cheers,
Tom

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: stuck at the beginning: how to compare text?

Post by JRL » Wed Jul 22, 2015 7:18 pm

Most likely the text acquired using GetTextInRect> has invisible characters such as spaces, tabs or carriage returns. You can test this by putting the acquired text in a message box. after your GetTextInRect> line, add something like:

Code: Select all

MDL>***%result%***
I suspect the message box will display something like:
  • ***TEXT
    ***
Indicating there is a carriage return being captured by the GetTextInRect> function. If there is a carriage return, you need to either remove that from the result:

Code: Select all

StringReplace>result,crlf,,result
Or test for its existence in the captured string:

Code: Select all

if>result=TEXT%crlf%
    TimeStamp>logfile, wording:Success
Else
    TimeStamp>logfile, wording:Failed
Endif
Note I removed the braces and quotes and also changed "ElseIf" to "Else"
Hope this makes sense. By the way, your English is very good.

schrauber
Newbie
Posts: 2
Joined: Wed Jul 22, 2015 11:55 am

Re: stuck at the beginning: how to compare text?

Post by schrauber » Fri Jul 24, 2015 5:13 pm

Thanks for the quick answer, and sorry for beeing late. Real life is a pain sometimes. Will test this at the weekend and come back to this thread with an update.

Thanks :)

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts