WebDriver - Trailing whitespace is added

Fixed Issue #14907415


Mark D.
Dec 1, 2017
This issue is public.
Found in
  • Microsoft Edge
Standard affected

Found in build #
Reported by 2 people

Sign in to watch or report this issue.

Steps to reproduce

In some cases I see that the Edge driver is adding an extra whitespace the the text string of an element I’m trying to match.
See the attachment for the active Li element and the text shown without a whitespace.

When I get this text with Watir via element.text

irb(main):013:0> div = browser.wait(:like => [:div, :class, ‘mp-tabpages breadcrumb clearfix’], :filter_by => :visible?)
=> #<Watir::Div: located: true; {:xpath=>"//div[contains(concat('’, normalize-space(@class), ‘’), ‘mp-tabpages breadcrumb clearfix’)]", :tag_name=>"div", :index=>0}>
irb(main):014:0> active_li = browser.find(:like => [:li, :class, ‘active’], :context => div)
=> #<Watir::LI: located: true; {:xpath=>"//div[contains(concat('’, normalize-space(@class), ‘’), ‘mp-tabpages breadcrumb clearfix’)]", :tag_name=>"div", :index=>0} --> {:xpath=>".//li[contains(concat('’, normalize-space(@class), ‘’), ‘active’)]", :tag_name=>"li", :index=>0}>
irb(main):015:0> element = browser.find(:like => [:div, :class, ‘note2’], :context => active_li, :filter_by => :exists?)
=> #<Watir::Div: located: true; {:xpath=>"//div[contains(concat('’, normalize-space(@class), ‘’), ‘mp-tabpages breadcrumb clearfix’)]", :tag_name=>"div", :index=>0} --> {:xpath=>".//li[contains(concat('’, normalize-space(@class), ‘’), ‘active’)]", :tag_name=>"li", :index=>0} --> {:xpath=>".//div[contains(concat('’, normalize-space(@class), ‘’), ‘note2’)]", :tag_name=>"div", :index=>0}>
irb(main):016:0> element.flash
=> #<Watir::Div: located: true; {:xpath=>"//div[contains(concat('’, normalize-space(@class), ‘’), ‘mp-tabpages breadcrumb clearfix’)]", :tag_name=>"div", :index=>0} --> {:xpath=>".//li[contains(concat('’, normalize-space(@class), ‘’), ‘active’)]", :tag_name=>"li", :index=>0} --> {:xpath=>".//div[contains(concat('’, normalize-space(@class), ‘’), ‘note2’)]", :tag_name=>"div", :index=>0}>
irb(main):017:0> element.text
=> "Standard Task - 289 "

It suddenly added a whitespace at the end of the string.
This only happens with Edge, not with FF/Chrome


Comments and activity

  • Oew I can’t edit my post anymore…
    I’m using Ruby + selenium and watir (via the lapis_lazuli gem which uses the syntax I use to find the element, but I can do the same with Watir/Selenium, results are the same).

  • Since the case is slightly different I created a new ticket for it. But it could very well be a duplicate of this one: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/5569343/

  • Workaround for now that I use if to always do element.text.strip

  • Microsoft Edge Team

    Changed Assigned To to “Steven K.”

  • Has this been fixed, if so in what Release 17134?
    I am using 16299 and it still has the same problem

  • Microsoft Edge Team

    Changed Title from “Trailing whitespace is added” to “WebDriver - Trailing whitespace is added”

  • Hi Neville,

    Are you seeing this issue where whitespace is getting added or the other possible duplicate issue where the whitespace is not getting removed?

    I am not able to reproduce this ticket’s issue.  I.e. I do not see whitespace getting added.  However, I am able to reproduce the issue where the extra whitespace is not removed.

    If you are able to repro this ticket’s issue, please provide a repro for me to test with.  A repro will significantly speed up the process.  :)


  • Microsoft Edge Team

    Changed Assigned To to “edgedevtoolstri”

    Changed Assigned To from “edgedevtoolstri” to “Long L.”

    Changed Status to “Confirmed”

  • @Steven K. Thanks for your reply. After your comment I looked again at the elements which I thought where adding a trailing white space, but indeed this is not the case. The space is in the element but is not being removed.
    Standard Task - 289
    So if the other ticket is covering that the fact that the white space is not being removed, this ticket can be closed.

  • I see the div is not shown as tekst. so here I try again
    Standard Task - 289

  • Ok, nevermind this markup. I also cannot edit them afterwards. But in Chrome development tools I do see a space behind the tekst when I inspect the element, but the trailing space is removed. When I inspect the element in Edge I do not see the trailing space in the inspector, but it’s added if I check the text of that element as described above. So could it be that the inspector is removing the trailing space correctly? Making it look like there is no trailing space, but Edge webdriver thinks there is a trailing space and does not remove it correcly (as covered in the other ticket you mentioned)?

  • See “trailing whitespace.PNG” for the difference between chrome and edge element inspector.

  • Microsoft Edge Team

    Changed Status from “Confirmed” to “Not reproducible”

  • Does the original HTML file have a space for ">Standard Task - 289 <"?  Can you provide the URL or the HTML file that you are testing with?

  • I cannot give you a url since it’s a private web application that requires a login which I’m not allowed to share. But he did tell me this

    • it’s element content. this should never be “trimmed”
    • It’s a “Title” generated by code. (using tab.label)
    • The attributes are in a different order (meaning at least one of the browsers is not showing the source, but the parsed and reserialized HTML) - here he is referring to the screenshot that shows the difference between the edge and chrome dev tools.

    So from that I conclude that the HTML does include the space (as shown in the chrome dev tools). I made a false assumption based on what I saw in the Edge dev tools (which was no space), making me think that Edge webdriver added a trailing white space. But in fact the issue is the same as the other ticket. There is a white trailing space which is not being removed. So this ticket can be closed.

  • Microsoft Edge Team

    Changed Status from “Not reproducible” to “Fixed”

  • Hi Mark,

    I wanted to let you know that this has been fixed.  Let us know if you see any issues in the latest Insider Release.

    The MS Edge Team

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

Sign in