element icon indicating copy to clipboard operation
element copied to clipboard

a convenience in API to locate an element in the (open) shadow dom

Open evaneus opened this issue 5 years ago • 2 comments

Is your feature request related to a problem? Please describe.

We use Custom Elements (with open mode for shadow root) Would be nice if there was a convenience to locate these elements for testing with Flood Element api.

Describe the solution you'd like

Maybe a special selector, like that provided with Stencil JS? https://stenciljs.com/docs/end-to-end-testing#find-an-element-in-the-shadow-dom

// Use the "piercing" selector >>> to query for an object inside a component's shadow root:
const el = await page.find('foo-component >>> .close-button');

see stencil implementation

Describe alternatives you've considered

Could use Browser.evaluate to find the element with js by getting element.shadowRoot and running a querySelector on that.

evaneus avatar Jul 13 '20 19:07 evaneus

Hi @evaneus, we'll release this soon but for now, you can work around by the following: https://www.npmjs.com/package/query-selector-shadow-dom, they have some examples at https://github.com/Georgegriff/query-selector-shadow-dom/blob/master/examples/puppeteer. Thanks

phileba avatar Jul 15 '20 08:07 phileba

How do we apply this solution to Flood Element 2.0? I cannot figure out how to register a custom selector with the 'browser' model versus the 'page' model.

eyemana avatar Jun 19 '23 17:06 eyemana