How to target and interact with Polymer tags using Puppeteer?
See original GitHub issueTell us about your environment:
- Puppeteer version: Current latest
- Platform / OS version: Windows 10
- URLs (if applicable):
- Node.js version: 11.6.0
(This link is possibly region blocked, I don’t know for sure) https://tinyurl.com/yd6qv9ok
I am attempting to interact with the pdf viewer for the above document, but the element that I am attempting to target is, and is nested inside of, a custom-built tag created using Polymer. How do I target, and click on, an element such as <viewer-pdf-toolbar>?
In the site’s own console window, these elements can be targeted like one would expect, by calling document.querySelector
with a selector such as ‘viewer-pdf-toolbar’, and it can even access the insides of shadow roots using /deep/.
This functionality does not appear to be supported by Puppeteer, is it related to the version of Chromium it is running? Would reverting to a version of Puppeteer that uses a version of Chromium prior to 63, (where /deep/ was removed. See this for details) allow the use of /deep/?
I have tried:
- Calling
await page.$('viewer-pdf-toolbar')
, resolves to null because it cannot find the element - Calling
await page.$$('viewer-pdf-toolbar
, resolves to an empty array for the same reason - Using
page.waitForSelector('viewer-pdf-toolbar')
, times out after 30 seconds, due to not finding the element - Targeting the element by querying the dom-module tag, which is the outermost container for every Polymer module
- Attempting to find a method to access the
document
object directly, to then calldocument.querySelector
, like in the console window
What is my use case for this?
My goal is to use Puppeteer to access the pdf viewer, and click on the download button to download the pdf document. If there are better, more elegant solutions to this problem, I am completely open to suggestions.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (5 by maintainers)
Top GitHub Comments
reply@reply.github.com
I don’t believe it’s a viable solution as the pdf comes from a site I have no jurisdiction over and is updated regularly, which means the urls change drastically.