(webdriverio): allow getHTML to pierce through Shadow DOM#12490
(webdriverio): allow getHTML to pierce through Shadow DOM#12490christian-bromann merged 12 commits intomainfrom
Conversation
| "css-shorthand-properties": "^1.1.1", | ||
| "css-value": "^0.0.1", | ||
| "grapheme-splitter": "^1.0.2", | ||
| "htmlfy": "^0.1.0", |
There was a problem hiding this comment.
this package is completely new, we cannot guarantee if it will be maintained and would rather go with a npm package that has already proven itself
There was a problem hiding this comment.
Unfortunately I couldn't find one, I tried various packages, some with higher download numbers that didn't work. The size of this package is fairly reasonable so I would be happy to fork and maintain it myself if needed. If you have an alternative suggestion for such a package, let me know.
| "@wdio/utils": "9.0.0-alpha.0", | ||
| "archiver": "^7.0.0", | ||
| "aria-query": "^5.0.0", | ||
| "cheerio": "^1.0.0-rc.12", |
There was a problem hiding this comment.
Seems like this is pretty much jquery, why not use the newly release jquery release directly instead?
There was a problem hiding this comment.
It just looks like jQuery but is actually a completely different package. cheerio is an HTML parser that allows to traverse and modify HTML within Node.js. We can't use jQuery as it requires a DOM API to be available which we don't have in Node.js.
Proposed changes
In #12446 we implemented some building blocks that allow us to pierce through the ShadowDOM. This patch enhances on this effort and widens support for piercing to more crucial commands like
getHTML. Users can now run snapshot tests that include the DOM structure of all underlaying Shadow Roots, e.g.:When using web components we often see comments like
<!--?lit$206212805$--><!--?lit$206212805$-->which are used to help the framework hydrate element correctly. Since these are not much helpful when snapshotting the DOM structure of elements, I also added an option that allows users to remove this.Note: there is a lot more we can do to manipulate and clean up the DOM structure before returning the result. I was thinking of
excludeElements: to remove elements from the snapshot that contain assets, e.g. like the SVG aboveexcludeAttributes: to remove attributes from elements that contain random values, e.g. like theidattribute of.ui5-button-textaboveI want to raise separate PRs for this.
Types of changes
This is a breaking change since we changed the interface of
getHTMLand now automatically pierce shadow roots which can impact users existing tests.Checklist
Backport Request
//: # (The current
mainbranch is the development branch for WebdriverIO v9. If your change should be released to the current major version of WebdriverIO (v8), please raise another PR with the same changes against thev8branch.)v9and doesn't need to be back-ported#XXXXXFurther comments
n/a
Reviewers: @webdriverio/project-committers