code: public String getText(WebElement element) {
          String text = element.getText();
          if (text != null) {
              // Safari driver does not return &nbsp; as normal spacce, while others do
              text = text.replace(NON_BREAKING_SPACE, ' ');
              // Safari driver does not return trim, while others do
              text = text.trim();
          }
          return text;
      }
docs: Gets element's text content.
  @param element element to get text() of.
  @return text, without trailing whitespace and with &nbsp; as normal spaces.