microsoft / playwright-test

Build a cross-browser end-to-end test suite with Playwright.
https://playwright.dev
Apache License 2.0
777 stars 34 forks source link

Bug(?): Webkit support on Ubuntu #244

Closed BillyBolton closed 3 years ago

BillyBolton commented 3 years ago

I could never get Webkit browsers to work locally (Ubuntu 20.10) but it works fine in my CI pipeline (CircleCi). I'm assuming this is because Webkit isn't supported on Ubuntu, is that correct -- especially in the case that headless=false? Otherwise, I'm not sure what could be wrong. Tests work fine with Chromium and Firefox. Here's the error I get:

  2) e2e.spec.ts:22:14 › [webkit] Index: CLIENT  Confirm Setup =====================================

    browserType.launch: Protocol error (Playwright.enable): Browser closed.
    ==================== Browser output: ====================
    <launching> /home/wbolton/.cache/ms-playwright/webkit-1446/pw_run.sh --inspector-pipe --headless --no-startup-window
    <launched> pid=10920
    [pid=10920][err] /home/wbolton/.cache/ms-playwright/webkit-1446/minibrowser-wpe/bin/MiniBrowser: error while loading shared libraries: libicui18n.so.66: cannot open shared object file: No such file or directory
    =========================== logs ===========================
    <launching> /home/wbolton/.cache/ms-playwright/webkit-1446/pw_run.sh --inspector-pipe --headless --no-startup-window
    <launched> pid=10920
    [pid=10920][err] /home/wbolton/.cache/ms-playwright/webkit-1446/minibrowser-wpe/bin/MiniBrowser: error while loading shared libraries: libicui18n.so.66: cannot open shared object file: No such file or directory
    ============================================================
    Note: use DEBUG=pw:api environment variable to capture Playwright logs.

    Error: 
        at Object.captureStackTrace (/home/wbolton/Desktop/dev/tdd-playwright-example/e2e/node_modules/playwright/lib/utils/stackTrace.js:48:19)
        at Connection.sendMessageToServer (/home/wbolton/Desktop/dev/tdd-playwright-example/e2e/node_modules/playwright/lib/client/connection.js:69:48)
        at Proxy.<anonymous> (/home/wbolton/Desktop/dev/tdd-playwright-example/e2e/node_modules/playwright/lib/client/channelOwner.js:64:61)
        at /home/wbolton/Desktop/dev/tdd-playwright-example/e2e/node_modules/playwright/lib/client/browserType.js:64:67
        at BrowserType._wrapApiCall (/home/wbolton/Desktop/dev/tdd-playwright-example/e2e/node_modules/playwright/lib/client/channelOwner.js:77:34)
        at BrowserType.launch (/home/wbolton/Desktop/dev/tdd-playwright-example/e2e/node_modules/playwright/lib/client/browserType.js:55:21)
        at MyEnv.beforeAll (/home/wbolton/Desktop/dev/tdd-playwright-example/e2e/node_modules/@playwright/test/out/index.js:53:67)
        at WorkerRunner._loadIfNeeded (/home/wbolton/Desktop/dev/tdd-playwright-example/e2e/node_modules/folio/out/workerRunner.js:92:79)
        at WorkerRunner.run (/home/wbolton/Desktop/dev/tdd-playwright-example/e2e/node_modules/folio/out/workerRunner.js:104:20)
        at process.<anonymous> (/home/wbolton/Desktop/dev/tdd-playwright-example/e2e/node_modules/folio/out/worker.js:92:28)
        at process.emit (events.js:315:20)
        at emit (internal/child_process.js:876:12)
        at processTicksAndRejections (internal/process/task_queues.js:85:21)

The test is really simple:

        test.only('Confirm Setup', async ({ indexPage }) => {
            await indexPage.navigateHome();
        })

This issue was present in previous versions of Playwright-Test. However, if needed my config is:

// config.ts

import { PlaywrightEnv, newTestType, setConfig, TestInfo, reporters, setReporters } from "@playwright/test";
import { IndexPage } from "./PO/IndexPage";

require('dotenv').config();
const baseURL = process.env.BASE_URL;

setConfig({
    testDir: "./tests",  // Search for tests in this directory.
    timeout: 30000,  // Each test is given 30 seconds.
    // timeout: 90000,  // Each test is given 90 seconds.
    retries: 0,  // Failing tests will be retried at most two times.
    workers: 5,
});

setReporters([
    // Report to the terminal with "line" reporter.
    // new reporters.line(),
    // Additionally, output a JUnit XML file.
    new reporters.junit({ outputFile: 'test-results/playwright-e2e-junit.xml', stripANSIControlSequences: true }),
    new reporters.list(),
]);

// Extend the default environment to add any test arguments, for example POMs.
class MyEnv extends PlaywrightEnv {
    async beforeEach(testInfo: TestInfo) {
        // Get all default arguments, including Page.
        const result = await super.beforeEach(testInfo);
        // Create your POM.
        const indexPage = new IndexPage(result.page, baseURL);
        // Return default arguments and new POM.
        return { ...result, indexPage };
    }
}

// Declare "indexPage" test argument for types in IDE.
export const test = newTestType<{ indexPage: IndexPage }>();
export { expect } from "@playwright/test";

// Run tests in three browsers.
const options = {
    // Launch options:
    headless: true,
    slowMo: 50,
    // Context options:
    // viewport: { width: 800, height: 600 },
    ignoreHTTPSErrors: true,
    // Testing options:
    // video: 'retain-on-failure',
    screenshot: 'only-on-failure',
};

// Run tests in three browsers.
test.runWith(new MyEnv('chromium', options), { tag: 'chromium' });
test.runWith(new MyEnv('firefox', options), { tag: 'firefox' });
test.runWith(new MyEnv('webkit', options), { tag: 'webkit' });
srguiwiz commented 3 years ago

I would pay attention to where it says

error while loading shared libraries: libicui18n.so.66: cannot open shared object file: No such file or directory

It runs well for us on one machine with Webkit in Ubuntu 20.04, which has a few libicui18n per

sudo find / -name *libicui18n*
laurentpayot commented 3 years ago

@BillyBolton Webkit is working fine on my Ubuntu 20.10 machine. Here is a list of apt packages required for webkit to work, be sure you have all of them: https://playwright.dev/docs/ci/#travis-ci

BillyBolton commented 3 years ago

Solved with: https://github.com/microsoft/playwright/issues/4236#issuecomment-718838311