Check if text exists - do x if it does do y if it doesn't


I’ve been trying to make UiPath check if a text box in SAP has a certain word in it (e.g sales). The word i’m searching for is a part of a longer sentence in the text box. However, I cannot seem to make it work with ‘get text’ or ‘text exists’ or even using an ‘anchor base’. All it has to do is check if the string is in the text box, run the ‘then’ if it’s there and the elseif if it’s not there. The ‘then’ is supposed to go back to the next item in the ‘for each’ loop i am working in.

When i use ‘text exists’ like in the picture below the true statement is supposed to go to next item in the ‘for each’ where as the ‘false’ statement is supposed to do a ‘type into’. What I think is happening (since I am not getting any error messages) is that no matter what is written in the text box and no matter what text i try to match it with, the ‘text exists’ only returns false. The if in the else works fine.

I have a few questions: does the string searched for in the ‘text exists’ have to be an exact match to whatever is in my text box? Can I put a variable instead of a string as the text I want to check for? Is it correct to use ‘continue’ to skip to next item in the ‘if’ or will this not work? (I have obviously not been able to check this since it never runs this path).

Can you help me make it actually check for the text? Thank you in advance

1 Like

As far as I know it had to be an exact match, I also did not see an option to use regex (but this might just not been mentioned)

my solution would be to just capture the whole text you want to check and use string.contains(string) to get the result you want

Please use “Contains” method instead of Text exists.
If condtion should be --“Your complete string”. Contains(“string2Find”)–

both solutions works, thank you

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