cauline
8 years agoContributor
I'm trying to use CheckProperty with RegExpressions.
Has anyone used RegExp with aqObject.CheckProperty? I am trying to locate string(s) within a 'innerText' property, while ignoring white spaces (\n \t\ and spaces). I am using JavaScript.
- 8 years ago
cauline wrote:
I am trying to verify property text of a Web Page table, but it has a bunch of control chars (\n \t) that I want to ignore:
You could process the textContent value to remove extra whitespace and replace the control characters with usual spaces:
var str = browser.___.textContent; str = str.replace(/\s+/g, ' '); // replace consecutive \r \n \t etc. with a single space str = aqString.Trim(str); // remove leading and trailing whitespace aqObject.CompareProperty(str, cmpEqual, "expected value", false);
Note the usage of CompareProperty instead of CheckProperty, because we check the variable value (str) rather than the textContent property directly. Also make sure the expected value has the same normalized format as the value being checked.