Skip to content

Shadow Dom Query #654

Answered by ankur22
cmoniot-gala asked this question in Q&A
Nov 17, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hi @cmoniot-gala,

xk6-browser doesn't transparently support shadow doms yet. We have a ticket open for a similar issue: #475.

For now you can use page.evaluate as a workaround to interact with elements in the shadow dom:

import { chromium } from 'k6/x/browser';

export default function () {
  const browser = chromium.launch({ headless: false });
  const page = browser.newPage();
  page.setViewportSize({ width: 1200, height: 1080 })

  page
    .goto('https://books-pwakit.appspot.com/', { waitUntil: 'networkidle' })
    .then(() => {
      page.evaluate(() => {
        document.querySelector('book-app').shadowRoot
        .querySelector('app-header')
        .querySelector('.toolbar-bottom')

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@cmoniot-gala
Comment options

Answer selected by cmoniot-gala
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
duplicate This issue or pull request already exists enhancement New feature or request
2 participants