Issue 1:
System info

Playwright Version: 1.36.0

Operating System: Windows

Browser: All

Source code

using Microsoft.Playwright;

using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var context = await browser.NewContextAsync();
var page = await context.NewPageAsync();

await page.GotoAsync("https://www.example.com");

var locator = page.Locator("//*[contains(@class, 'foo']").First;

await locator.IsVisibleAsync();

Console.ReadKey();

Steps

Create a new .NET console app.

Add a reference to Microsoft.Playwright package.

Replace the contents of Program.cs to the above code.

Expected

The string '//*[contains(@Class, 'foo']' is not a valid XPath expression.

Actual

The string './/*[contains(@Class, 'foo']' is not a valid XPath expression.

Difference

The actual contains a prefix . when printing the locator.

Issue 2:
System info

@playwright/test Version 1.36.0

Operating System: macOs 13.4.1

Browser: all

Other info: "playwright-lighthouse": "^3.1.0"

This Error Started when I installed playwright-lighthouse and tried to import that.

Source code

I am trying to run this test

`
import { playAudit } from 'playwright-lighthouse';
import { test } from '@playwright/test';

test.describe('account settings tests', () => {
test('verify account details visible', async ({ page }) => {
await page.goto(MYURL);

await playAudit({
page: page,
port: 9222,
thresholds: {
accessibility: 50,
'best-practices': 50,
performance: 50,
pwa: 50,
seo: 50,
},
});
});
});`

It fails on the first line the import for playwright-lighthouse

Config file

// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './playwright/e2e/lighthouse/accountSettings',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: 'https://bidder-react-stage.liveauctioneers.com/',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});

Steps

[Run the test]

[...]

Expected

[Describe expected behavior]

Actual

[Describe actual behavior]

THIS IS THE ERROR THAT I AM GETTING

require() of ES Module /Users/ryanpetersen/dev/bidder-react/node_modules/playwright-lighthouse/index.js from /Users/PATH/TO/TEST/FILE.spec.ts not supported. Instead change the require of index.js in /Users/PATH/TO/TEST/FILE.spec.ts to a dynamic import() which is available in all CommonJS modules.