webdriverio: [๐Ÿ› Bug]: getText() is returning the text value along with preceding spaces

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

latest

Mode

WDIO Testrunner

Which capabilities are you using?

{
 maxInstances: 15,
 browserName: 'safari',
 browserVersion: 'latest',
 os: 'OS X',
 osVersion: 'Big Sur',
 acceptInsecureCerts: true
}

What happened?

$(locator).getText() is giving the text content with preceding spaces.

this happens only with safari. Chrome and edge works fine with the same code.

What is your expected behavior?

getText() to return the text content without adding any additional spaces

How to reproduce the bug.

use $(locator).getText() in safari BigSur

Relevant log output

NA

Code of Conduct

  • I agree to follow this projectโ€™s Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

@rameshkumarj can you provide an simple example which allows us to reproduce this? It can be on any random website. I believe in general the returned text should be not trimmed. WebdriverIO doesnโ€™t do any operations on it. The WebDriver protocol defines the get element text as basically doing this:

document.querySelector(selector).innerText

and innerText is defined to return โ€œthe elementโ€™s text content "as renderedโ€ which I guess can be ambiguous.