webdriver getText returns String with leading and trailing whitespaces

External Issue #5569343


Nov 24, 2015
This issue is public.
Reported by 16 people

Sign in to watch or report this issue.

Steps to reproduce


Repro Steps:

<div id="test"> leading and trailing whitespaces </div>
WebElement test = driver.findElement(ById(“test”));
return test.getText();

Expected Results:

like described in the selenium documentation

Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, without any leading or trailing whitespace.

Actual Results:

Dev Channel specific:



0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “Mara P.”

      Changed Assigned To from “Mara P.” to “Ben B.”

      Changed Status to “Confirmed”

      Changed Assigned To from “Ben B.” to “Reinhold D.”

      Changed Assigned To from “Reinhold D.” to “IE S.”

      Changed Status from “Confirmed” to “External”

    • We are also seeing this.

    • Is there any reason why this is an external issue?
      i am still seeing the same behaviour with 3.14393 and Selenium 2.53.0

    • Any updates on this issue? Seeing the same behavior with Selenium 3.0.1 and Selenium2Library 1.8.0. The issue is accurately described here: http://stackoverflow.com/questions/40000072/string-with-leading-and-trailing-whitespaces-on-using-gettext-method-with-micr

    • Having the same issue here any get text() returns useless spaces so I have to adjust every Java tests with .trim() only for this specific driver… Using Selenium 3.0.1 on Windows 10 Edge 14

    • Hello,

      Thank you for providing this information about the issue. We confirmed the problem, and implemented a solution on a later build of Edge. We are resolving this issue as a duplicate of an existing internal bug report. We look forward to additional feedback you may have on how we can improve Microsoft Edge.

      Best Wishes,
      The MS Edge Team

    • I still see this problem with current Edge 15.15063 and it is now October.
      @james can you point me to where this problem is fixed, or some likely timeline for a fix to be released somewhere in publicly visible versions?

    • We see this with Edge 41.16299.15.0 — retrieving element text returns a value with an erroneous trailing single space character.

    • We are also facing the issue with edge driver Version: 5.16299 and Microsoft Edge 41.16299.248.0.

    You need to sign in to your Microsoft account to add a comment.

    Sign in