[1.1.4] Region.text(): adds new-line at the end of the recognized string

Asked by Linda

My code:
    a = find("1557282546849.png").text()
    b = "64"
    print a
    print "--"
    print b
    if a == b:
        print 'pass'
    else:
        print 'diff'

Result:
64

--
64
diff

How to do with no empty string?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

ok, seems to be some weird behavior:
it is not an empty string, but a new-line, that is added to the "64"

I have to check.

workarounds:

use
a = find("1557282546849.png").text().strip()
... which removes whitespace from start and end of string

or
a = find("64.png").collectWordsText()[0]
... see: https://sikulix-2014.readthedocs.io/en/latest/region.html#extracting-text-from-a-region

Revision history for this message
Linda (kkea55534) said :
#2

Thanks RaiMan, that solved my question.