Forum Discussion
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:
aqObject.CheckProperty(browser.pageUatUlineComProductDetailH101.form.panelDvchart.table.table, "textContent", cmpEqual, "\n\nMODELNO.\nPRICE EACH\nADD TOCART\n\n\n1\n2\n6+\n\n\nH-101\n$17\n$15\n$13\n\nADD\n\n", false);
When I run the CheckProperty with the cmpEqual test, I simply want to ignore the newline and tab characters.
Thanks,
C
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.