Ranorex Spy, Recorder, and Studio.
Posts: 17
Joined: Wed Jun 24, 2020 8:17 am


Post by damien » Tue Jan 05, 2021 1:55 pm


I'm using the method " ValidateFileContainsText" to check if a certain value exists in that file.
Do I have the possibility to check if a certain value doesn't exist in that file ? How can I do that easily ?

Thanks in advance !

User avatar
Certified Professional
Certified Professional
Posts: 16
Joined: Tue Jan 19, 2021 5:24 pm
Location: Colorado, US

Re: ValidateFileContainsText

Post by vseaver » Tue Jan 19, 2021 8:49 pm

Hi Damien,

The best way to achieve this functionality would be to make a custom global collection and add your own custom function to that. There is coding involved but you'll only have to change 1 character. This is actually not as difficult as it sounds. The way I would go about doing is as follows:

Create a new global collection

Then copy the function from the code for ValidateFileContainsText into your newly created global collection.

Rename it to ValidateFileDoesNotContainsText

Where it does this check:

Code: Select all

 if (line.IndexOf(text, StringComparison.OrdinalIgnoreCase) != -1)
change the != to ==.

You may also want to change the log messages. But really that's up to you.

Then your new function will be available for use the same way ValidateFileContainsText. You'll even be able to access is the same way, and use the same variables names.

Best of luck!
Sales Engineer @ Ranorex

Posts: 17
Joined: Wed Jun 24, 2020 8:17 am

Re: ValidateFileContainsText

Post by damien » Tue Apr 13, 2021 3:28 pm

I only see your post right now.
And thanks it works perfectly fine!