How did I find this?
I will tell you.
I made a custom Keyword: my.StringUtils
:
package my
public class StringUtils {
/**
* convert the input string
* while escaping all non ASCII characters of which UNICODE code point is larger than 128
*
* E.g.,
* String s = "Hello\u2010world"
* println(s) // --> "Hello‐world"
* println(StringUtils.escapeNonAsciiChars(s)) // --> "Hello\u2010world"
*/
static String escapeNonAsciiChars(String str) {
StringBuilder sb = new StringBuilder()
for (int i = 0; i < str.length(); i++) {
int codepoint = str.codePointAt(i)
if (codepoint < 128) {
sb.append(str.charAt(i))
} else {
sb.append("\\u").append(String.format("%04X", codepoint))
}
}
return sb.toString()
}
}
I made a Test Case TC1
:
def Test_Title = 'DuckDuckGo — Privacy, simplified.'
def escapedTitle = my.StringUtils.escapeNonAsciiChars(Test_Title)
println escapedTitle
When I ran the test case, I got the following output in the console.
2021-02-11 09:52:05.134 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/checkDuckDuckGoPageTitle
2021-02-11 09:52:06.901 DEBUG testcase.checkDuckDuckGoPageTitle - 1: Test_Title = "DuckDuckGo — Privacy, simplified."
2021-02-11 09:52:06.910 DEBUG testcase.checkDuckDuckGoPageTitle - 2: escapedTitle = StringUtils.escapeNonAsciiChars(Test_Title)
2021-02-11 09:52:06.961 DEBUG testcase.checkDuckDuckGoPageTitle - 3: println(escapedTitle)
DuckDuckGo \u2014 Privacy, simplified.
2021-02-11 09:52:06.980 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/checkDuckDuckGoPageTitle
I am sure you have \u2014
(EM Dash) in your CSV file.