content with display: none is still captured (does not match innerText)
See original GitHub issueThe PageObject.text
helper returns hidden text. While — by comparison — innerText
does not.
Given
<span id="example">
<span>foo</span>
<span style="display: none">bar</span>
<span>baz</span>
</span>
const page = PageObject.create({
example: PageObject.text('#example')
});
Expected
find('#example').innerText.trim() // => "foo baz"
page.example // => "foo baz"
Actual
find('#example').innerText.trim() // => "foo baz"
page.example // => "foo bar baz"
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Div innerText loses new lines after setting display to none
I believe the issue is that there are no newlines, just new block -level children of the div with inner text nodes containing...
Read more >The poor, misunderstood innerText
They don't include hidden elements ("display:none", "visibility:hidden"), which makes sense too. And they don't include contents of <select> ...
Read more >Element selectors | Playwright 中文文档
Selectors are strings that point to the elements in the page. They are used to perform actions on those elements by means of...
Read more ><input type="text"> - HTML: HyperText Markup Language | MDN
If no validation constraints are in place for the input (see ... This must be a non-negative integer value smaller than or equal...
Read more >Using Cypress
How do I get an element's text contents? Cypress commands yield jQuery objects, so you can call methods on them. If you're trying...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Alonski would be glad to accept a PR
oh… I’ve just faced the issue when upgraded ec-page-object in a lib from 1.16 to 1.17. This seems to be a regression introduced in https://github.com/san650/ember-cli-page-object/pull/466
I believe we should revert
contains
to keep using$.text()
instead of.innerText