Page 1 of 1

How to trim a value coming from getValue

Posted: Tue Aug 23, 2016 12:10 pm
by bygones
Hi,

i have a recording in which I use getValue from an element, store it in a variable and then compare this with the text of a later component.

Unfortunately the value contains spaces like

Code: Select all

"        text     "
, and the final component to validate has only

Code: Select all

 "text"
Currently I use AttributeRegEx as comparison, which works, but I would rather trim the value I receive.

Can someone explain me step by step how to trim a value when receiving it via getValue in a recording module ?

Thanks

Re: How to trim a value coming from getValue

Posted: Tue Aug 23, 2016 1:25 pm
by krstcs
Trimming the value will require using User Code. It cannot be done in the action table.

Assuming your actual value is stored in the variable named "actual" and your expected value is in "expected":

Code: Select all

string actual = "      text      ";
string expected = "text";

Validate.AreEqual(actual.Trim(), expected.Trim());
I put the Trim() function on both to ensure that both are treated exactly the same way, just in case.