admin管理员组

文章数量:1123425

How can I access an element (.slider) which is inside #shadow-root (closed) using Playwright?

body class='override vsc-initialized'
 <div-id='root' class='override'>
 #shadow-root (closed)
  <div-id='root' class='override'>
  <div-id='icons'>
   <div-class='slider' style='left: 0px';">

I am trying to locate .slider on the page:

        await page.locator('.slider').hover()
        await page.mousedown()
        await page.mouse.move(x=100,y=100)

I keep getting this error because playwright does not see that element. What I can do to scroll this slider?

patchright._impl._errors.TimeoutError: Locator.hover: Timeout 30000ms exceeded. Call log:

  • waiting for locator(".slider")

本文标签: pythonHow to use an element inside ShadowRoot using PlaywrightStack Overflow