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
65.99k stars 3.6k forks source link

[Feature] Support CentOS #9199

Open udit0802 opened 3 years ago

udit0802 commented 3 years ago

Edit by maintainers

Hey everybody!

There's now an experimental support for all linux distributions using our browser container image mcr.microsoft.com/playwright. If you can run this container image on your linux distribution, then you can instruct @playwright/test to connect to it and run browsers inside the container.

Please give it a try and let us know what you think here: https://github.com/microsoft/playwright/issues/26482


We have our CI machines setup on centos7. I am trying to integrate in our integration tests which runs on jenkins on centos machines. Able to run tests using chrome but facing issues with following browsers:

Chromium :

<launching> /home/centos/.cache/ms-playwright/chromium-920619/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --user-data-dir=/tmp/playwright_chromiumdev_profile-GyWOJw --remote-debugging-pipe --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --no-startup-window
[2021-09-28T13:04:55.123Z]     <launched> pid=20094
[2021-09-28T13:04:55.123Z]     [pid=20094][err] /home/centos/.cache/ms-playwright/chromium-920619/chrome-linux/chrome: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /home/centos/.cache/ms-playwright/chromium-920619/chrome-linux/chrome)
[2021-09-28T13:04:55.123Z]     [pid=20094] <process did exit: exitCode=1, signal=null>
[2021-09-28T13:04:55.123Z]     [pid=20094] starting temporary directories cleanup

This issue was earlier reported on 1.

Edge :

browserType.launch: Chromium distribution 'msedge' is not supported on linux
[2021-09-28T13:04:55.120Z] 
[2021-09-28T13:04:55.120Z]         at Object._baseTest.extend.browser.scope [as fn] (/apps/jnkn/workspace/EvergreenShoots-CMgt_PR-1560/main/integration-tests/playwright-e2e/node_modules/@playwright/test/lib/test/index.js:127:40)
[2021-09-28T13:04:55.120Z]         at Fixture.setup (/apps/jnkn/workspace/EvergreenShoots-CMgt_PR-1560/main/integration-tests/playwright-e2e/node_modules/@playwright/test/lib/test/fixtures.js:73:73)
[2021-09-28T13:04:55.121Z]         at FixtureRunner.setupFixtureForRegistration (/apps/jnkn/workspace/EvergreenShoots-CMgt_PR-1560/main/integration-tests/playwright-e2e/node_modules/@playwright/test/lib/test/fixtures.js:312:5)
[2021-09-28T13:04:55.121Z]         at FixtureRunner.resolveParametersAndRunHookOrTest (/apps/jnkn/workspace/EvergreenShoots-CMgt_PR-1560/main/integration-tests/playwright-e2e/node_modules/@playwright/test/lib/test/fixtures.js:297:23)
[2021-09-28T13:04:55.121Z]         at WorkerRunner._runTestWithBeforeHooks (/apps/jnkn/workspace/EvergreenShoots-CMgt_PR-1560/main/integration-tests/playwright-e2e/node_modules/@playwright/test/lib/test/workerRunner.js:449:7)

Issue reported earlier on 2

Webkit:

browserType.launch: Host system is missing dependencies!
[2021-09-28T13:04:55.121Z] 
[2021-09-28T13:04:55.121Z]       Install missing packages with:
[2021-09-28T13:04:55.121Z]           sudo apt-get install gstreamer1.0-libav
[2021-09-28T13:04:55.121Z] 
[2021-09-28T13:04:55.121Z]       Missing libraries we didn't find packages for:
[2021-09-28T13:04:55.121Z]           libnotify.so.4
[2021-09-28T13:04:55.121Z]           libopus.so.0
[2021-09-28T13:04:55.121Z]           libwoff2dec.so.1.0.2
[2021-09-28T13:04:55.121Z]           libharfbuzz-icu.so.0
[2021-09-28T13:04:55.121Z]           libgcrypt.so.20
[2021-09-28T13:04:55.121Z]           libgstapp-1.0.so.0
[2021-09-28T13:04:55.121Z]           libgstbase-1.0.so.0
[2021-09-28T13:04:55.121Z]           libgstreamer-1.0.so.0
[2021-09-28T13:04:55.121Z]           libgstpbutils-1.0.so.0
[2021-09-28T13:04:55.121Z]           libgstaudio-1.0.so.0
[2021-09-28T13:04:55.121Z]           libgsttag-1.0.so.0
[2021-09-28T13:04:55.121Z]           libgstvideo-1.0.so.0
[2021-09-28T13:04:55.121Z]           libgstgl-1.0.so.0
[2021-09-28T13:04:55.121Z]           libgstcodecparsers-1.0.so.0
[2021-09-28T13:04:55.121Z]           libgstfft-1.0.so.0
[2021-09-28T13:04:55.121Z]           libjpeg.so.8
[2021-09-28T13:04:55.121Z]           libpng16.so.16
[2021-09-28T13:04:55.121Z]           libopenjp2.so.7
[2021-09-28T13:04:55.121Z]           libwebpdemux.so.2
[2021-09-28T13:04:55.121Z]           libwebp.so.6
[2021-09-28T13:04:55.121Z]           libenchant.so.1
[2021-09-28T13:04:55.121Z]           libsecret-1.so.0
[2021-09-28T13:04:55.121Z]           libhyphen.so.0
[2021-09-28T13:04:55.121Z]           libicui18n.so.66
[2021-09-28T13:04:55.121Z]           libicuuc.so.66
[2021-09-28T13:04:55.121Z]           libevdev.so.2
[2021-09-28T13:04:55.121Z]           libGLESv2.so.2
[2021-09-28T13:04:55.121Z] 
[2021-09-28T13:04:55.121Z] 
[2021-09-28T13:04:55.121Z]         at Object._baseTest.extend.browser.scope [as fn] (/apps/jnkn/workspace/EvergreenShoots-CMgt_PR-1560/main/integration-tests/playwright-e2e/node_modules/@playwright/test/lib/test/index.js:127:40)
[2021-09-28T13:04:55.121Z]         at Fixture.setup (/apps/jnkn/workspace/EvergreenShoots-CMgt_PR-1560/main/integration-tests/playwright-e2e/node_modules/@playwright/test/lib/test/fixtures.js:73:73)
[2021-09-28T13:04:55.121Z]         at FixtureRunner.setupFixtureForRegistration (/apps/jnkn/workspace/EvergreenShoots-CMgt_PR-1560/main/integration-tests/playwright-e2e/node_modules/@playwright/test/lib/test/fixtures.js:312:5)
[2021-09-28T13:04:55.121Z]         at FixtureRunner.resolveParametersAndRunHookOrTest (/apps/jnkn/workspace/EvergreenShoots-CMgt_PR-1560/main/integration-tests/playwright-e2e/node_modules/@playwright/test/lib/test/fixtures.js:297:23)
[2021-09-28T13:04:55.121Z]         at WorkerRunner._runTestWithBeforeHooks (/apps/jnkn/workspace/EvergreenShoots-CMgt_PR-1560/main/integration-tests/playwright-e2e/node_modules/@playwright/test/lib/test/workerRunner.js:449:7)

Issue reported earlier on 3

As many organizations like ours uses centos machines as their infrastructure, this feature will have a wider impact and will help many developers. Request playwright team to have a look at this request.

Thanks!!

tov324 commented 10 months ago

+1

1ManSmoking commented 9 months ago

Managed to run playwright 1.39.0 on CentOs 7 with firefox browser by building glibc-2.28 from sources, patchelf and adding some missing libraries. But chromium (also patched with patchelf) fails - PlaywrightException: Failed to read message from driver, pipe closed.

Guess its some kind of driver issue. Did anyone do something similar and can assist? Thanks a lot!

Knowledge-Labz commented 7 months ago

Heads up, since the solution quoted in here installs a static version, turns out we could make playwright with chromium work without a problem on our Rocky8 servers with a simplification of @kumaraditya303 fantastic answer! This command replaces playwright install-deps .

dnf install -y alsa-lib \ at-spi2-atk \ at-spi2-core \ atk \ bash \ cairo \ cups-libs \ dbus-libs \ expat \ flac-libs \ gdk-pixbuf2 \ glib2 \ glibc \ gtk3 \ libX11 \ libXcomposite \ libXdamage \ libXext \ libXfixes \ libXrandr \ libXtst \ libcanberra-gtk3 \ libdrm \ libgcc \ libstdc++ \ libxcb \ libxkbcommon \ libxshmfence \ libxslt \ mesa-libgbm \ nspr \ nss \ nss-util \ pango \ policycoreutils \ policycoreutils-python-utils \ zlib

chrisdavies commented 6 months ago

To add to @knowledge-labz answer, I had to also install dbus-glib in order for Firefox to work (on Fedora).

mario16 commented 6 months ago

Heads up, since the solution quoted in here installs a static version, turns out we could make playwright with chromium work without a problem on our Rocky8 servers with a simplification of @kumaraditya303 fantastic answer! This command replaces playwright install-deps .

dnf install -y alsa-lib \ at-spi2-atk \ at-spi2-core \ atk \ bash \ cairo \ cups-libs \ dbus-libs \ expat \ flac-libs \ gdk-pixbuf2 \ glib2 \ glibc \ gtk3 \ libX11 \ libXcomposite \ libXdamage \ libXext \ libXfixes \ libXrandr \ libXtst \ libcanberra-gtk3 \ libdrm \ libgcc \ libstdc++ \ libxcb \ libxkbcommon \ libxshmfence \ libxslt \ mesa-libgbm \ nspr \ nss \ nss-util \ pango \ policycoreutils \ policycoreutils-python-utils \ zlib

This works for an Amazon Linux 2 image on AWS (with yum package manager instead of dnf). Thanks!

hafiz031 commented 6 months ago

I tried running my scrapy-playwright project and faced similar issue. I managed to run my project in CentOS 7 by dockarising it under Ubuntu 20.04 base image. I could not use Ubuntu 22.04 (current latest LTS) due to the following error: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ...

yeyuchen198 commented 5 months ago

真是可惜官方不支持Cent OS,虽然网上有一些魔法可以使用,但也多多少少有些问题。 最后我还是用Docker算了:docker pull mcr.microsoft.com/playwright/python:v1.32.0-focal 亲测这个镜像可以正常使用,但是有些镜像是坏的!

注意:不要使用docker pull mcr.microsoft.com/playwright/python:v1.40.0-jammy 实际测试,这个镜像是坏的,里面没有playwright,连pip install xxx也报错!!! 千万不要安装这个镜像!!!!!!

bbhxwl commented 5 months ago

真是可惜官方不支持Cent OS,虽然网上有一些魔法可以使用,但也多多少少有些问题。 最后我还是用Docker算了:docker pull mcr.microsoft.com/playwright/python:v1.32.0-focal 亲测这个镜像可以正常使用,但是有些镜像是坏的!

注意:不要使用docker pull mcr.microsoft.com/playwright/python:v1.40.0-jammy 实际测试,这个镜像是坏的,里面没有playwright,连pip install xxx也报错!!! 千万不要安装这个镜像!!!!!!

我一直不能在docker 里面运行,不知道为什么。

sksharma0 commented 2 months ago

I was having issues with using playwright on aws lambda inside a centos python docker image, was able to solve with the help of @kumaraditya303 using below dockerfile: https://github.com/sksharma0/playwright-on-centos/blob/master/Dockerfile putting it here for reference