How to find text on web page with not-case-sensitive

I use:
via

xpath= //*[contains(text(),“some text”)]

or this

Boolean result = WebUI.verifyTextPresent("some text", false, FailureHandling.CONTINUE_ON_FAILURE)

but it didn`t work

Hi,

question about your xpath, why it’s used single quotes there xpath= ‘xxxxx’?
what you are really doing, some more info would be nice to know

https://docs.katalon.com/katalon-studio/tutorials/detect_elements_xpath.html#deal-with-dynamically-changing-elements

hello,

cannot see there that xpath string is between single quotes ’ ’ as your xpath is
//*[contains(text(),“some text”)]

Hi @tod2020,
Can you try the xpath //*[contains(translate(text(), ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’, ‘abcdefghijklmnopqrstuvwxyz’) ,“some text”)]

it doesn’t work

You should use the matches() function with an ‘i’ flag:

//*[matches(text(), '(.+?)', 'i')]

where:

  • text() is the ‘attribute’ you’re checking

  • ‘(.+?)’ is a regex pattern to match

  • ‘i’ is a flag indicating case-insensitivity

Check here for more on the use of the matches() function.

@tod2020, did you write “some text” in lower case? Actually my solution is to translate the text to lower case before checking if it contains the desired words.

is it Correct?

Unfortunately no. To reiterate what I said above:

The argument that you will need to configure for your purposes is likely the regex pattern (the ‘(.+?)’ argument). While I’m not a regex pro (in fact, I despise regex), something like this might work:

//*[matches(text(), '^some text\$', 'i')]