Skip to content

How to use Codeception with web components using shadow? #6824

Open
@mschop

Description

@mschop

Hi,

we are using web components with shadow DOM. Is it possible to access the shadow DOM with built-in functions of Codeception?

How to reproduce?

  1. Add this component
class MyComponent extends WebComponent {
  constructor() {
        super()
        this.attachShadow({mode: 'open'})
    }

    connectedCallback() {
        this.shadowRoot.innerHTML = '<div id=test></div>'
    }
}

window.customElements.define('my-component', MyComponent)
  1. Adding the component to the DOM.
<my-component />
  1. Now try to access it from Codeception:
$I->waitForElementVisible('#test'); // not working

I didn't find a way to access the div in a shadow root.

The only way I would see is, to execute js with $I->executeJS(); but relying on this function for testing a complete application seems horrible to me.

Any ideas or tips?

Best Regards
mschop

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy