-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Feature] support for Chrome extension popup testing #5593
Comments
This feature is in pretty high demand here: puppeteer/puppeteer#2486 |
From a Chrome extension point of view, popups are fundamentally the same as other pages hosted on It would be amazing if this feature was implemented in a way that allowed for testing other contexts like options pages, etc. |
Particularly considering manifest v3 has done away with background pages! Wtf?! The whole change is really starting to feel non-sensical at this point. Regardless it would be nice to still have a way to test moving forward. |
Does anybody have current workarounds that will let us open the extension popup? |
I didn't find any workaround to actually open the popup window. My workaround is finding the extension id and use it to open a page in tab. Code is here: https://github.com/xcv58/Tab-Manager-v2/blob/master/packages/integration_test/util.ts#L55-L59 |
@pirate It's not the same, but you might try using the undocumented |
Another workaround, dispatching the
|
After the popup is displayed using a browser action, is there any way to obtain the popup page in Playwright? |
Please, for the love of Bob...make it so Playwright can interact with extension popup elements. |
+1 on this as I believe this issue is blocking the popup displayed by |
any updates on this issue? |
I'm curious what the scope of this feature is. Depending on the extension an amount of popup behavior can be tested with the As I understand it currently there is no way to test behavior of an extension that requires a website to be open while the popup is open. |
@fedorareis I believe the point is to be able to write tests that confirm a user flow involving an extension popup works end to end.
For clarity my case is a little different...i would like to test the following flow end to end:
Hopefully this helps clarify. |
This is fully supported now with the https://playwright.dev/docs/chrome-extensions ! |
That's amazing progress, thanks @aslushnikov! On a read-through of those docs, I don't see anything about extension context menu or menubar icon testing. How can we use this new functionality to test browser extension context menus as described here: #5593 (comment) |
If am getting this right, the support was for the headless mode, not for the extension popup testing. I don't think this [Feature] should be considered closed. Thoughts? |
@aslushnikov can our tests now interact with the |
Hey folks! This issue's scope was popup testing, which is supported. (see https://playwright.dev/docs/chrome-extensions)
@pirate context menu testing is not possible as of today. Please file a separate feature request!
@Ameerplus this would be an issue request to Chromium. There's some new headless mode that might be helpful, please see the discussion here: https://bugs.chromium.org/p/chromium/issues/detail?id=706008
@mattemoore if they can't, then please file a separate issue! Narrow-scope issues are way easier to manage & gauge interest. |
I wanted to trigger the extension popup using a button click on my main page and do something on the extension within the context of tab/website. After performing some actions on the extension popup, I need to verify that the changes on the main page is caused by the extension. For example, Is this possible in the current implementation in Playwright? I read https://playwright.dev/docs/chrome-extensions doc and I couldn't find a workaround for my usecase. Please help me confirm whether this is possible or not in playwright. |
Did you ever get this to work? I am in the same situation. |
I wasn't able to interact with the pop up page of our chrome extension until I did the following using playwright-pytest with python 3.10:
Without the time.sleep of 3 (YMMV) seconds I'm not able to interact with anything on the pop up page. I know it's an anti-pattern but nothing else worked. I tried page.wait_for_load_state(), page.wait_for_selector(), page.wait_for_url(), and element.wait_for(). Nothing worked except the static wait. Hope this helps someone. From what @aslushnikov said above, it seems like a chromium issue is causing this so who knows when/if it will be fixed but it sure would be nice to interact with that dang extension pop up. Can anyone tell me why the time.sleep is the only thing that works here and none of the built in waiting features in playwright? |
@aslushnikov the amount of functionality that can be tested by navigating to Please reopen this issue. |
Please re-open this issue as this is not implemented. I have a chrome extension where we expect the user to open the popup on a particular page and then inject a script on that page. Just opening Please implement a way to open the extension popup in a way that a user would interact with the extension before calling this fully supported |
Please re-open this issue as this is not implemented. I am in the same situation. |
@aslushnikov Can this please be re-opened? This is still an issue for me as well. The hack-y solution I listed above (using time.sleep(3) before trying to click on a button in the extension popup #5593 (comment)) isn't preferable as it slows down testing and it doesn't allow me to fully interact with the extension popup. |
Is there any new progress on this issue? I need to interact with the popup extension page directly instead of using chrome-extensions:///popup.html. Because not all extensions support this method. |
For anyone testing Chrome extensions where yout auth has to go through test('can login', async ({ page, extensionId }) => {
await page.goto(`chrome-extension://${extensionId}/newtab.html`);
const signInButton = page.getByRole('button', { name: 'Sign in' });
await expect(signInButton).toBeVisible();
await signInButton.click();
const browserContext = page.context();
// Salesforce Login popup
const popupPage = await browserContext.waitForEvent('page');
await popupPage.waitForLoadState('domcontentloaded');
await expect(popupPage).toHaveURL(/login\.salesforce\.com/);
await popupPage.getByLabel('Username').fill(<username>);
await popupPage.getByLabel('Password').fill(<password>);
await popupPage.getByRole('button', { name: 'Log In' }).click();
await popupPage.close();
}); |
I managed to open the popup from playwright (properly, as if the user clicked on the button, not in a new tab as the doc suggests)
However, I can't find a way to actually interact with popup HTML elements :( |
The |
(originally coming from #5586)
Playwright can test background pages: https://playwright.dev/docs/api/class-chromiumbrowser?_highlight=extension
However, there's no support to test extension pop-ups.
The text was updated successfully, but these errors were encountered: