Skip to content
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

[BUG] Test execution gets stuck when running through Playwright extension in Vscode #20399

Closed
ghost opened this issue Jan 26, 2023 · 7 comments · Fixed by #21631
Closed

[BUG] Test execution gets stuck when running through Playwright extension in Vscode #20399

ghost opened this issue Jan 26, 2023 · 7 comments · Fixed by #21631
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Jan 26, 2023

Context:

  • Playwright Version: 1.30.0
  • Playwright Test for VSCode 1.0.6
  • Operating System: Mac
  • Node.js version: v16.15.0
  • Browser: Chromium

Code Snippet

Test:

import { test, chromium } from '@playwright/test';
import path from 'path';

test('Reproduce defect', async function ({ page }) {
  await page.goto('https://google.com');

  const browser = await chromium.launch({
    headless: false,
    args: [
      '--use-fake-device-for-media-stream',
      '--use-fake-ui-for-media-stream'
    ],
  });
  const context = await browser.newContext();
  const pageNewContext = await context.newPage();

  await pageNewContext.goto('https://www.microsoft.com');
});

Playwright config:

import { type PlaywrightTestConfig } from '@playwright/test';
import dotenv from 'dotenv';

dotenv.config();

const config: PlaywrightTestConfig = {
  name: 'tests',
  use: {
    ignoreHTTPSErrors: true,
    acceptDownloads: true,
    headless: true,
    viewport: { width: 1280, height: 720 },
  },
  testDir: 'test/tests/',
  reporter: [['list'], ['html']],
  reportSlowTests: null,
  timeout: 200_000,
};

export default config;

Describe the bug

When I run this test through Playwright extension in Vscode test execution gets stuck on await chromium.launch().
Screenshot 2023-01-26 at 17 28 18

But when I run it through: playwright test --grep 'Reproduce defect' the test works as expected and opens new chromium inside the test

@pavelfeldman
Copy link
Member

You seem to be creating a brand new browser when you already have a browser with an opened page created for you by the test harness. You might want to specify the launch arguments in the playwright config and just use the provided page.

@ghost
Copy link
Author

ghost commented Jan 26, 2023

You seem to be creating a brand new browser when you already have a browser with an opened page created for you by the test harness. You might want to specify the launch arguments in the playwright config and just use the provided page.

In my scenarios I need to have one browser with default args (defined in playwright.config) and one more with another args to get different audio/media streams etc.
So to run new context with args I can only use await chromium.launch() according to documentation and it doesn't work with Playwright extension.

@pavelfeldman
Copy link
Member

Do you have a Show browser setting checked in the Testing panel?

@ghost
Copy link
Author

ghost commented Jan 27, 2023

Yes.
But it gets stuck in all combinations: when "Show browser" is checked/unchecked and when I pass "headless: false/true" in chromium.launch().

@pavelfeldman pavelfeldman self-assigned this Jan 30, 2023
@raulparada
Copy link

For whoever has the same issue and doesn't mind the downgrade, version 0.2.10 handles this correctly. Looking forward to the fix though :) thank you!

@pavelfeldman
Copy link
Member

Ok, trying to reproduce this, but things work for me. Created a new project with these files and things work. Note though that your config is broken - it has malformed ternary operator as a reporter value.

@ghost
Copy link
Author

ghost commented Feb 14, 2023

Yes, there was a mistake in config. I fixed it.
I also tried to reproduce in new project and looks like the issue is not reproducible with unchecked "Show browser" checkbox. But it was reproducible with checked "Show browser".
You can try to run with checked/unchecked "Show browser". I am pretty sure that it should be reproduced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants