'Verify Element Text' errors - text case rendered differently between browsers

I’m having difficulties using ‘Verify Element Text’ with regards to the case (upper or lower) of text, in conjunction with cross-browser testing.

I have a piece of text on the page: ‘MY SETTINGS’. Inspecting the element shows the text as ‘My Settings’, so I think there is some JavaScript (or similar) that is capitalising the text, so that on the page, it renders as ‘MY SETTINGS’.

The problem I have is that I see different results for what Katalon regards as actual text, between different browsers.

In Microsoft Edge, the actual text (as observed in error-stack-trace.txt) is shown as ‘My Settings’, but in Chrome, it shows as ‘MY SETTINGS’. This means that whatever I record as the expected text in my data file, either Edge or Chrome will fail, as the text doesn’t match one or the other.

I would imagine that there’s some way of checking which browser is being used, and therefore follow a path suitable for that browser, but I want to avoid complexity, and also that might then mean having two columns of data in my data file (one upper case, one not), which I really want to avoid.

Does anyone have any suggestions for a more straightforward solution?

Perhaps it’s possible to capitalise the captured (actual) text before checking against expected text, therefore making the text case the same before checking?

All suggestions gratefully welcomed - thanks :slight_smile:

You could manage the capured text in script using stringUtils available in org.apache.commons.lang3.

https://commons.apache.org/proper/commons-lang/javadocs/api-release/index.html

Search the page for lowerCase, Uppercase, etc.

Hi Russ,

Thanks for that, I’ll take a look.

In the meantime (in case this is useful for anyone else), I got round this by getting the text and storing as a variable, then using .toUpperCase(), then comparing the expected text (upper case in my data file) to the actual text converted to upper case:

mySettingsLabel = WebUI.getText(findTestObject(‘Page_My Profile/label_mysettings’))

mySettingsLabel = mySettingsLabel.toUpperCase()

WebUI.verifyMatch(mySettingsLabel, content_mysettings, false)

Cheers,
Kevin

1 Like

Thanks! This is exactly what I needed - worked a treat! :slight_smile:

1 Like

How to deal with sensitive case?
I want to compare ‘Test site’ with the value that get from texbox ‘TEST SITE’

e.g.
def SearchValue = ‘Test site’
getTextValue = WebUI.getAttribute(findTestObject('Object_test/Page_BackendSite/General_Info_Name),
‘value’)
WebUI.verifyMatch(SearchValue.toString(), getNameValue, false)

I see function toString().CASE_INSENSITIVE_ORDER but I don’t know how to use.
If you know, please details me.

Thank you.