Problem

When working with TMP text fields, particularly those where user input is provided, the TMP component will append a non-printable Unicode (0xE2, 0x80, 0x8B) or ASCII "?" character (0x3f) that can sometimes result in a failed assertion during testing. When running your test, a field validation can fail while the visible text values are the same. For example:


Test:

api.SetInputFieldText("//FilterInputTxt[@name='TextMeshPro InputField']", "America");
Assert.IsTrue(api.WaitForObjectValue("//*[@name='Text']/fn:component('TMPro.TextMeshProUGUI')", "text", "America"));

Output:

Wait for object value expired for object 54bdb9d4-3616-4ce1-a2ed-1cf8e750b95b.
Waiting for value = 'America' [0x41, 0x6D, 0x65, 0x72, 0x69, 0x63, 0x61]
Last value = 'America' [0x41, 0x6D, 0x65, 0x72, 0x69, 0x63, 0x61, 0x3F]
UnityEngine.Debug:LogError (object)
gdio.unity_agent.GDIOLogger:Error (object) (at c:/temp/github/gdio99/src/gdio.unity_agent/gdio_unity_agent/GDIOLogger.cs:74)
gdio.unity_agent.GDIOAgent:ProcessWaitForObjectsAndValues () (at c:/temp/github/gdio99/src/gdio.unity_agent/gdio_unity_agent/GDIOAgent.cs:744)
gdio.unity_agent.GDIOAgent:Update () (at c:/temp/github/gdio99/src/gdio.unity_agent/gdio_unity_agent/GDIOAgent.cs:2714)


To ignore the non-printed character when using WaitForObjectValue, add the following config value to the GameDriver agent in /Assets/GDIO/Resources/config/gdio.unity_agent.config.txt:

<unicode><ignoreZeroWidthSpace enabled="true"/></unicode>


To validate the contents of the field via the API client, you will need to include the full contents of the field. For example:


bool bWaitForStr = api.WaitForObjectValue("/[@name='Canvas']/[@name='InputField (TMP)']/[@name='Text Area']/[@name='Text']/fn:component('TMPro.TextMeshProUGUI')", "text", "Hello GDIO API", true, 10);

string returnedString = api.GetObjectFieldValue<string>("/[@name='Canvas']/[@name='InputField (TMP)']/[@name='Text Area']/[@name='Text']/fn:component('TMPro.TextMeshProUGUI')/@text");

byte[] utf8bytes = System.Text.Encoding.UTF8.GetBytes(returnedString);
byte[] asciibytes = System.Text.Encoding.ASCII.GetBytes(returnedString);

if ("Hello GDIO API\u200b".Equals(System.Text.Encoding.UTF8.GetString(utf8bytes)))
Console.WriteLine("UTF8 does Match");
else
Console.WriteLine("UTF8 does NOT Match");

if ("Hello GDIO API\x3f".Equals(System.Text.Encoding.ASCII.GetString(asciibytes)))
Console.WriteLine("ASCII does Match");
else
Console.WriteLine("ASCII does NOT Match");