Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
Selenium [JavaScript] - Find elements under embedded element with Shadow DOM [ #shadow-root (user-agent) ]

I am unable to click elements of shadow dom elements.

var propelement = await wdriver.findElement(By.xpath('//*[@id="rptLoadingFrame"]'));
var pdf_url = await propelement.getAttribute('src')
wdriver.get(pdf_url);
//var download1  = await wdriver.findElement(By.xpath('//*[@id="download"]'));
//download1.click();

await wdriver.executeScript("document.querySelector('#viewer').shadowRoot.querySelector('#toolbar').shadowRoot.querySelector('#downloads').shadowRoot.querySelector('#download').shadowRoot.querySelector('#icon').click()");

Getting below error message

JavascriptError: javascript error: Cannot read properties of null (reading 'shadowRoot')

  1. PDF viewer is embedded within iframe and no DOM visible accept <slot> element inside Embed element with #Shadow Root (user-agent)

    enter image description here

  2. When I access SRC mentioned in iframe got below DOM i.e. PDF viewer. I want to click "Download" button to download the PDF.

    enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!