New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve targeting devtools panel iframe created by an extension #4247
Comments
@antross sure, this'd work. Would you mind sharing why do you want to automate DevTools with Puppeteer?
This is a dupe of #2548. We're experimenting with different approaches to get it working. |
@aslushnikov Thanks for the response!
What I'm most interested in at the moment is automating a panel created by the devtools extension we've been working on for webhint. I'm using Puppeteer to drive the extension panel as part of a basic end-to-end test to ensure the user flow is working. At the moment anything that could activate the panel and get a reference would be good enough, but in the future I'd also like to validate integration points like linking to the Elements and Sources panels. That would likely involve a bit more direct automation of the devtools.
Understood. Thanks for the reference. |
@antross I actually like your subtle hack in "Proposal 1". It's not too bad, and given that you're probably the first ever client to test Chrome DevTools extension - let's keep it like this for now. Once there are some other clients, we'll expand our API surface. "Proposal 2" will be covered with OOPIFs. I'll close this for now - there's nothing to do at the moment to address this. Thanks for reaching though! |
Just wanted to add a note that we're attempting to run E2E testing for the Axe extension as well. The methods we have to run through to get an isolated instance are probably extremely hacky and require heavy usage of the chrome devtools protocol. We couldn't find another way to capture screenshots of the extension without having full page screenshots. |
+1 I also own a Chrome extension with a non-trivial DevTools panel which I would like to be able to test with Puppeteer. An explicitly supported means of getting access to the panel would be very useful for us. |
+1 My use case is to test emulation pane in DevTools; the hack is how I can get to the "Toggle device mode" button (edited: or I can hack the url simply by making the DevTools dockable). |
Filing as the workaround listed in #3699 wasn't sufficient to target content inside the
iframe
created for a devtools extension panel. I was able to eventually get this working, but it required accessing private APIs (as did the workaround in #3699) so I'd like to see this scenario improved and officially supported.Here's what it took:
✔ Good: Installing the extension and opening the devtools on a page of my choosing works well.
⚠ Issue 1: Getting a puppeteer
Page
pointing to the devtools requires some URL-matching and a hack as theTarget
type isother
(this could be loaded in a separate browser tab as described in #3699, but that also requires accessing private data).🙏 Proposal 1: Expose the devtools as a known target type that can return a
Page
.✔ Good: Activating the extension devtools tab so it's iframe gets created is awkward, but at least this uses public APIs. It takes advantage of keyboard shortcuts as suggested in #3699 - though I'm iterating just once in reverse as the extension is always the last tab.
⚠ Issue 2: At this point the example in #3699 shows how to get a reference to the tab element in the devtools, but that is outside of the extension panel's
iframe
and I want to debug the content inside the frame. UnfortunatelydevtoolsPage.frames()
doesn't contain the extension panel frame, but I was able to work around this because the panel did appear inbrowser.targets()
.🙏 Proposal 2: Fix returning the extension panel frame in
devtoolsPage.frames()
:Let me know if you'd prefer to have the proposals split into two separate issues. I wanted to present them together initially for context on what it took to interact with a devtools extension panel and to better help anyone else who may be trying to do the same.
The text was updated successfully, but these errors were encountered: