unable to find text with underscore in it

Does anyone know if having underscore in the text to search needs some special formatting while performing a search?

My script is failing to find the word “Darwin_Templates” and can find “Darwin” fine? These words are inside a drop-down that my script scrolls through after expanding it.

So this call works: WaitFor 15, text:“Darwin”, searchRectangle: ((330, 250), (620, 450))
But this fails to find the word: WaitFor 15, text: “Darwin_Templates”, searchRectangle: ((330, 250), (620, 450))
I am attaching the screenshot that has the dropdown.


Here are a few thoughts:

Can you find the underscore character by itself without the surrounding text? If not, then insert the character using the charToNum feature (hint: the underscore is 95) to see if that helps.

Check to ensure that “trim” is not turned off in the text style properties. The default is on, so to turn it off “Trim: no” will be mentioned.

It is also possible to manually reduce the area that is searched so that the underscore is ignored. This will remove more area than the Trim feature.

Please post what works for you.

The OCR system almost always omits underscores and treats the character as a space.

You should be able to find the text if you replace the underscore in your search string with a space.

If explicitly identifying the underscore is relevant to the test then you will probably need to use an image reference instead of an OCR Text definition.