It's as simple as that:
How can I get Browser.text.include?
, or Ruby in general, to be case insensitive for that specified command?
It's as simple as that:
How can I get Browser.text.include?
, or Ruby in general, to be case insensitive for that specified command?
One of the easiest ways is to downcase or upcase the text that you're reading:
Browser.text.downcase.include?
Then, you need to make sure that your desired text is supplied in all lowercase.
You can use String#match with a regular expression. e.g.:
("CaseSensitive".match /SENSITIVE/i) != nil
That will return true if there is a case-insensitive match, false otherwise. So for the above example, it returns true, as 'SENSITIVE' is found within 'CaseSensitive'.
For your example:
(Browser.text.match /yourString/i ) != nil
© 2022 - 2024 — McMap. All rights reserved.