Fixed whitespace replace in text content

When there are repetitive tabs or new lines they should all be replaced with a single space character.

Also the `text()` method in the Selenium driver could have the same replacement with a single regular expression.