webdriverio/webdriverio

[💡 Feature]: Introduce a `children` command that returns the children of an element as `WebdriverIO.ElementArray`

Open

#12.536 aberto em 21 de mar. de 2024

Ver no GitHub
 (1 comment) (0 reactions) (0 assignees)JavaScript (1.793 forks)batch import
Idea 💡help wanted

Métricas do repositório

Stars
 (6.029 stars)
Métricas de merge de PR
 (Mesclagem média 15d 15h) (48 fundiu PRs em 30d)

Description

Is your feature request related to a problem?

While this feature is less interesting for e2e testing where you shoot straight for an element, in unit and component tests it might be indeed valuable to iterate over the children of an element.

Describe the solution you'd like.

Add a children command to the WebdriverIO.Element scope that allows the following option:

interface ChildrenOptions {
  // @default false
  withinShadowRoot?: boolean
}

Meaning that if I call await $('elem').children() I get the direct children of the element. If the element has a shadowroot then I get the elements of the light dom. If the user sets withinShadowRoot to true it returns the direct children of the shadow root.

Describe alternatives you've considered.

n/a

Additional context

Inspired by work done in https://github.com/ionic-team/stencil/pull/5498

Code of Conduct

  • I agree to follow this project's Code of Conduct

Guia do colaborador