microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.63k stars 3.65k forks source link

[Bug]: Chromium driver is not coming up, always running in the background #33378

Open JyotiPrakashMallick opened 4 hours ago

JyotiPrakashMallick commented 4 hours ago

Version

1.47.1

Steps to reproduce

I am facing a strange issue with Playwright, whenever I am trying to run my spec file the chromium driver nor Firefox driver coming up. Rather it run in the background and it is very difficult for me to debug the test cases.

I am running with Node Version 20.12.1 Npm version : 10.8.3

OS : Windows 11

This is my PlaywrightConfig.ts file i tried with both headless: true | false

import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
  testDir: './tests',
  outputDir: 'results',
  timeout: 80 * 1000,
  expect: {
    timeout: 80000
  },
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 0 : 0, //Changing this to 0 for as we don't want to retry on CI
  workers: process.env.CI ? 1 : undefined,
  reporter: [
    ['list'],
    ['junit', { outputFile: 'results/junit.xml' }]
  ],
  use: {
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
    headless: true,
    ignoreHTTPSErrors: true,

  },
  projects: [
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'] },
    },
    // {
    //   name: 'firefox',
    //   use: { ...devices['Desktop Firefox'] },
    // },
  ],
});

I was fearing may be the PowerShell execution policy must be stopping the browser to come up and change the policy as well. Also tried to keep PlaywrightConfig.js file and tried with both headless: true | false. But no luck, can someone help me what must be the issue.

Also checked if there is any instance of chromium running in the background by going to task manager and check. But there are no such driver running.

Tried to run with administrator privilege but not working, observing similar behavior.

The same configuration work on my colleagues machine and the chromium browser open up. My sample spec file.

import { test } from '@playwright/test';
import { Steps } from '../support/steps/index.ts';
import { Apiendpoints } from '../support/configs/apiendpoints.ts';
import { PartnerLogoutStep } from '../support/steps/partner.logout.step.ts';

test.describe('[PARTNER]: HOME PAGE',
  { annotation: { type: 'Home Page Module', description: 'Validate the home pages and various elements inside the home page' } }, () => {

    let steps: Steps;
    test.beforeEach(async ({ page }) => {
      steps = new Steps(page);
    });

    test.afterEach(async ({ page }) => {
      const logoutPartner = new PartnerLogoutStep(page);
      await logoutPartner.partnerLogout();
      await page.close();
    });

    /**
     * Test case to validate successful open the About Us page.
     * @param {Page} page - The Playwright page object.
     */
    test("TC-28: Validate various text, elements and links displayed on partner home page.", {
      annotation: [
        { type: 'Partner Module', description: 'Home Page Validation!' },
      ],
    }, async ({ page }) => {
      await page.goto(Apiendpoints.base_url);
      await page.waitForLoadState("networkidle");
      await page.waitForTimeout(2000);

      await steps.partnerLoginStep.partnerLogin();
      await page.waitForTimeout(2000);

      await steps.partnerLoginStep.keyboardHandler();
      await page.waitForTimeout(2000);

      await steps.partnerLoginStep.continueToPartner();
      await page.waitForTimeout(4000);

    });
  });

Let me know if any more information required, but the same spec file working on my colleagues machine and the chromium browser open up and the test ran through.

Expected behavior

Chromium browser should open up and iterate through.

Actual behavior

Chromium browser not opening up rather it is running in the background.

Additional context

Tried installing chromium one more time from menu,

Image

Environment

System : OS : Windows 11 IDE : Visual Studio Code Node Version 20.12.1 Npm version : 10.8.3

Skn0tt commented 3 hours ago

Hi there! Greetings to Hyderabad :)

In your Playwright config, you have headless: true. This makes the tests run in the background. Try removing that line.

JyotiPrakashMallick commented 3 hours ago

Hi @Skn0tt, thank you for prompt answer but I tried with headless: false and observing the similar behavior. I reported in my question.

Skn0tt commented 3 hours ago

Sorry, looks like didn't read far enough. If it works on your colleague's machine but not on yours, then it's likely I also won't be able to reproduce it because it's caused by something specific to your machine. I see you're using VS Code. Is there a chance that you have the 'Show browsers' checkbox in the Playwright Extension unchecked? See https://playwright.dev/docs/getting-started-vscode#run-tests-and-show-browsers.