Odd Characters Appended to Variable

I have a function that reads in time (format 00:00:00) from two sources. The function then performs a simple subtraction (time1 – time2) to obtain a difference. Then it runs a comparison on the difference and if the time difference falls within a certain threshold, it records pass, else it will record a fail.

Super simple

When I run this function in the test, the string “contcr” appends to the time. In the logs, you will see the time recorded as it should be with no “contcr” string appended to it. However, the script will fail and it will tell me that it cannot perform an arithmetic operation on 00:00:00contr and 00:00:00contr. After I pause the script, in the “Locals, Globals, Universals” column to the right in the Run window I see the proper time recorded, but with an arrow pointing to the time recorded and stored in the variable and after the arrow is “contcr”.

I ended up double clicking on the variable in the tree and a text field box appeared with the proper recorded time and underneath the recorded time is “contcr”. I erased the “contcr” sting and hit save. I thought that may have been the fix (i.e. garbage characters hanging around).

So, from what I can tell “contcr” is not really being appended to the time that was recorded (info in the logs), but Eggplant for some reason is doing this on its own. There is nothing in the Sensetalk source code that tells Eggplant to append anything to any variable.

If I write test code and step through the function standalone, everything is fine. When I run the full test, “contcr” appends to the value held in the time variable. I tried several different code changes, and I even tried a keepCharacters() function that another colleague had suggested, and when I run it standalone, I’m good. Even when I step through the function everything is fine.

When a colleague runs a test case that is very similar to mine, he runs the same function that I run (no differences in code) and his passes. So, I have a feeling that there is something odd going on with my IDE, but I have no clue what is going on.

Any thoughts?

IDE settings?

I CANNOT post the code to this forum as it is code that is on a classified system.

Can you show what the values for time1 and time2 are before you try to calculate the difference?

Dave’s a pro, but if you can post a screenshot I could take a stab at it.
You can export your Eggplant Preferences in case you think you have something wonky that your colleague doesn’t. Eggplant > Export Preferences
You could also try copying your colleague’s script file so that you have exactly what they have. This would strongly indicate an issue with Preferences. You could also have them try your *.script, or the whole suite.
Another thing to consider might be SUT differences between yourself and them.
It is also possible to set the OCR tool to read only “Valid Characters” and give it only numbers and time punctuation, but that is kind of a lame work-around of course.
Another recommendation that may not really apply to your needs: Many problems my users have with OCR I get around by simply having them double-click or triple-click the area where the time/data is and then fetching it from remoteclipboard. Folks often turn to OCR when they don’t really need to, but I understand that there are situations where it is needed.

Verify that you don’t have something weird in Text Style. I’ve mistakenly left weird stuff in there before:

You could obfuscate the code example that triggers the fail if you have hardcoded search text that is classified… just replace your classified data with dummy data. the syastem is classified… the script it just sensetalk?

1 Like

@StephenHamilton , I spoke with Lindsey, and it sounds like you are working together on a workaround. I am not certain that there is anything that I could add to her KB, but she can always reach out.

Update:
It sounds like the OCR Engine thinks that there is a newline in the read text. Try this.

put ReadText(your properties, etc) into myValue
split myValue by newline
delete item 2 of myValue

All - Thank you for the comments and help. All of you made some great points. I ended up solving the issue a long time ago and did not come back afterward. So, I apologize for that. I also won’t share how I ended up fixing the issue, because it is embarrassing :sweat_smile:.