[Question] Testing an extension's content-script
See original GitHub issueI have an extension that I would like to test using playwright. I’m currently able to load up my extension on Chromium as shown in the examples, but that’s about all I can do at this point.
Creating a new page defaults to creating it in incognito mode, regardless of whether a BrowserContext
is created or not. By default, extensions are disabled in incognito mode… ergo my extension cannot be tested.
What am I doing wrong?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
javascript - How do i test content-scripts in chrome extensions ...
I created test extension for this. It navigates to the predefined list of pages and checked for expected modifications on each page ...
Read more >Content scripts - MDN Web Docs - Mozilla
A content script is a part of your extension that runs in the context of a particular web page (as opposed to background...
Read more >Chrome Extensions: Content Scripts - Programming with Text
In this video, I cover " content scripts " for chrome extensions. The content script is a JavaScript file that runs in the...
Read more >Advanced chrome extension development - Educative.io
Learn the 24 patterns to solve any coding interview question without getting lost in a maze ... sendMessage() api to the content script...
Read more >Chrome Extensions getting started guides
Overview of all Chrome Extensions getting started guides. ... Table of contents ... choosing a project structure, and using Typescript.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I found a way to do that programmatically:
You should use
chromium.launchPersistent
to access default profile and test extension content scripts.Also, you can pierce shadow dom via:
await page.click('css=body > extensions-manager >> css=#items-list >> css=extensions-item >> css=#detailsButton');
(we’ll get rid of those css= over time)