Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect whitespaces for Get Element Text command #1682

Open
christian-bromann opened this issue Sep 2, 2022 · 0 comments
Open

Respect whitespaces for Get Element Text command #1682

christian-bromann opened this issue Sep 2, 2022 · 0 comments

Comments

@christian-bromann
Copy link
Member

christian-bromann commented Sep 2, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant