Respect whitespaces for Get Element Text command
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 718
- Forks
- 228
- PR merge metrics
- No merged PRs in 30d
Description
Currently Safari and Chrome behave different when it comes to getting text from an element. Safari respects whitespaces while Chrome trims it. E.g.:
Safari Example (using WebdriverIO)
2022-09-02T14:21:21.635Z INFO webdriver: Initiate new session using the WebDriver protocol
2022-09-02T14:21:21.701Z INFO webdriver: [POST] http://localhost:4444/session
2022-09-02T14:21:21.701Z INFO webdriver: DATA {
capabilities: { alwaysMatch: { browserName: 'safari' }, firstMatch: [ {} ] },
desiredCapabilities: { browserName: 'safari' }
}
2022-09-02T14:21:22.404Z INFO webdriver: COMMAND navigateTo("https://emberjs.com/")
2022-09-02T14:21:22.404Z INFO webdriver: [POST] http://localhost:4444/session/7E10C958-7FF4-442D-9BF2-B6D633CA8581/url
2022-09-02T14:21:22.404Z INFO webdriver: DATA { url: 'https://emberjs.com/' }
2022-09-02T14:21:23.829Z INFO webdriver: COMMAND setWindowRect(null, null, 1200, 900)
2022-09-02T14:21:23.829Z INFO webdriver: [POST] http://localhost:4444/session/7E10C958-7FF4-442D-9BF2-B6D633CA8581/window/rect
2022-09-02T14:21:23.829Z INFO webdriver: DATA { x: null, y: null, width: 1200, height: 900 }
2022-09-02T14:21:23.856Z INFO webdriver: RESULT { y: 38, x: 0, width: 1200, height: 900 }
2022-09-02T14:21:23.857Z INFO webdriver: COMMAND findElement("css selector", ".navbar-list li:nth-child(1)")
2022-09-02T14:21:23.857Z INFO webdriver: [POST] http://localhost:4444/session/7E10C958-7FF4-442D-9BF2-B6D633CA8581/element
2022-09-02T14:21:23.857Z INFO webdriver: DATA { using: 'css selector', value: '.navbar-list li:nth-child(1)' }
2022-09-02T14:21:23.976Z INFO webdriver: RESULT {
'element-6066-11e4-a52e-4f735466cecf': 'node-6D18E52A-FD46-4D09-A408-A63F3D709611'
}
2022-09-02T14:21:23.985Z INFO webdriver: COMMAND elementClick("node-6D18E52A-FD46-4D09-A408-A63F3D709611")
2022-09-02T14:21:23.985Z INFO webdriver: [POST] http://localhost:4444/session/7E10C958-7FF4-442D-9BF2-B6D633CA8581/element/node-6D18E52A-FD46-4D09-A408-A63F3D709611/click
2022-09-02T14:21:26.244Z INFO webdriver: COMMAND findElement("css selector", ".navbar-list li:nth-child(1) ul li:nth-child(1) a")
2022-09-02T14:21:26.245Z INFO webdriver: [POST] http://localhost:4444/session/7E10C958-7FF4-442D-9BF2-B6D633CA8581/element
2022-09-02T14:21:26.245Z INFO webdriver: DATA {
using: 'css selector',
value: '.navbar-list li:nth-child(1) ul li:nth-child(1) a'
}
2022-09-02T14:21:26.314Z INFO webdriver: RESULT {
'element-6066-11e4-a52e-4f735466cecf': 'node-3A05A2C4-2792-43FB-B762-0C42D3DE9CC2'
}
2022-09-02T14:21:26.315Z INFO webdriver: COMMAND getElementText("node-3A05A2C4-2792-43FB-B762-0C42D3DE9CC2")
2022-09-02T14:21:26.315Z INFO webdriver: [GET] http://localhost:4444/session/7E10C958-7FF4-442D-9BF2-B6D633CA8581/element/node-3A05A2C4-2792-43FB-B762-0C42D3DE9CC2/text
2022-09-02T14:21:26.354Z INFO webdriver: RESULT
Ember.js Guides
2022-09-02T14:21:26.354Z INFO webdriver: COMMAND deleteSession()
2022-09-02T14:21:26.355Z INFO webdriver: [DELETE] http://localhost:4444/session/7E10C958-7FF4-442D-9BF2-B6D633CA8581
Chrome Example (using WebdriverIO)
2022-09-02T14:29:13.431Z INFO webdriver: Initiate new session using the WebDriver protocol
2022-09-02T14:29:13.490Z INFO webdriver: [POST] http://localhost:4444/session
2022-09-02T14:29:13.490Z INFO webdriver: DATA {
capabilities: { alwaysMatch: { browserName: 'chrome' }, firstMatch: [ {} ] },
desiredCapabilities: { browserName: 'chrome' }
}
2022-09-02T14:29:14.568Z INFO webdriver: COMMAND navigateTo("https://emberjs.com/")
2022-09-02T14:29:14.568Z INFO webdriver: [POST] http://localhost:4444/session/94809431bf47218af7ba0b0d6c26d84d/url
2022-09-02T14:29:14.568Z INFO webdriver: DATA { url: 'https://emberjs.com/' }
2022-09-02T14:29:16.156Z INFO webdriver: COMMAND setWindowRect(null, null, 1200, 900)
2022-09-02T14:29:16.156Z INFO webdriver: [POST] http://localhost:4444/session/94809431bf47218af7ba0b0d6c26d84d/window/rect
2022-09-02T14:29:16.156Z INFO webdriver: DATA { x: null, y: null, width: 1200, height: 900 }
2022-09-02T14:29:16.261Z INFO webdriver: RESULT { height: 900, width: 1200, x: 22, y: 60 }
2022-09-02T14:29:16.262Z INFO webdriver: COMMAND findElement("css selector", ".navbar-list li:nth-child(1)")
2022-09-02T14:29:16.263Z INFO webdriver: [POST] http://localhost:4444/session/94809431bf47218af7ba0b0d6c26d84d/element
2022-09-02T14:29:16.263Z INFO webdriver: DATA { using: 'css selector', value: '.navbar-list li:nth-child(1)' }
2022-09-02T14:29:16.270Z INFO webdriver: RESULT {
'element-6066-11e4-a52e-4f735466cecf': '86f66ee1-a564-4a05-b332-474f4c21033a'
}
2022-09-02T14:29:16.272Z INFO webdriver: COMMAND elementClick("86f66ee1-a564-4a05-b332-474f4c21033a")
2022-09-02T14:29:16.272Z INFO webdriver: [POST] http://localhost:4444/session/94809431bf47218af7ba0b0d6c26d84d/element/86f66ee1-a564-4a05-b332-474f4c21033a/click
2022-09-02T14:29:18.295Z INFO webdriver: COMMAND findElement("css selector", ".navbar-list li:nth-child(1) ul li:nth-child(1) a")
2022-09-02T14:29:18.295Z INFO webdriver: [POST] http://localhost:4444/session/94809431bf47218af7ba0b0d6c26d84d/element
2022-09-02T14:29:18.295Z INFO webdriver: DATA {
using: 'css selector',
value: '.navbar-list li:nth-child(1) ul li:nth-child(1) a'
}
2022-09-02T14:29:18.303Z INFO webdriver: RESULT {
'element-6066-11e4-a52e-4f735466cecf': '6c0fe3a9-26db-4374-a674-b6704f5f20bd'
}
2022-09-02T14:29:18.304Z INFO webdriver: COMMAND getElementText("6c0fe3a9-26db-4374-a674-b6704f5f20bd")
2022-09-02T14:29:18.304Z INFO webdriver: [GET] http://localhost:4444/session/94809431bf47218af7ba0b0d6c26d84d/element/6c0fe3a9-26db-4374-a674-b6704f5f20bd/text
2022-09-02T14:29:18.312Z INFO webdriver: RESULT Ember.js Guides
2022-09-02T14:29:18.312Z INFO webdriver: COMMAND deleteSession()
2022-09-02T14:29:18.312Z INFO webdriver: [DELETE] http://localhost:4444/session/94809431bf47218af7ba0b0d6c26d84d
I suggest to add a WPT test that includes this example. IMHO given we are talking about visible text I'ld suggest to define what this means if possible and add a sentence to trim possible whitespaces. WDYT?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Get Element Text command and the Safari and Chrome examples in this issue, then review the related WebDriver specification wording and WPT coverage. Define how visible-text whitespace should be handled, add a WPT test covering the discrepancy, and document the resulting trimming behavior in the specification.
Written by the indexing model from the issue text.
Assessment
- Domain
- api, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100