Investigations - Playwright Automation
Overview
Notes
Initialization Note
$ npm init playwright@latest
Resolution
Cookie in test
-
https://stackoverflow.com/questions/64211501/add-cookies-in-playwright-test
-
https://playwright.dev/docs/api/class-browsercontext#browser-context-add-cookies
-
tips script:
$ cat mysb.json | jq | egrep -v '"expirationDate":|"hostOnly": false,|"httpOnly": false,|"sameSite": "unspecified",|"secure": false,|"session": false,|"storeId": "0",'
Create a test with codegen and debug
Screenshot on Failure
Using Proxy
-
https://minerva.mamansoft.net/Notes/Playwrightのテストでプロキシサーバーを経由
-
https://scrapingant.com/blog/how-to-use-a-proxy-in-playwright
-
https://playwright.dev/docs/test-configuration#network
-
https://github.com/microsoft/playwright/issues/2131
socks5://...
-
Waiting
-
await page.waitForTimeout(1000);
Tips
Debugging with Browser
Checking Ideas
-
Change the behavior by
-
https://stackoverflow.com/questions/70179441/check-if-element-is-visible-in-playwright
-
https://minerva.mamansoft.net/Notes/Playwrightで要素がvisibleかどうかを確認
-
https://stackoverflow.com/questions/70179441/check-if-element-is-visible-in-playwright
-
https://chercher.tech/python-playwright/playwright-python-check-if-element-exists
-
hmmm… is this the only way..?
-
Parent Element
iframe
Unstructured
On WSL
-
Some missing dependencies
browserType.launch: ╔══════════════════════════════════════════════════════╗ ║ Host system is missing dependencies to run browsers. ║ ║ Missing libraries: ║ ║ libnss3.so ║ ║ libnssutil3.so ║ ║ libsmime3.so ║ ║ libnspr4.so ║ ║ libatk-1.0.so.0 ║ ║ libatk-bridge-2.0.so.0 ║ ║ libcups.so.2 ║ ║ libdrm.so.2 ║ ║ libatspi.so.0 ║ ║ libXcomposite.so.1 ║ ║ libXdamage.so.1 ║ ║ libXrandr.so.2 ║ ║ libgbm.so.1 ║ ║ libxkbcommon.so.0 ║ ║ libpango-1.0.so.0 ║ ║ libcairo.so.2 ║ ╚══════════════════════════════════════════════════════╝ browserType.launch: ╔══════════════════════════════════════════════════════╗ ║ Host system is missing dependencies to run browsers. ║ ║ Missing libraries: ║ ║ libgtk-3.so.0 ║ ║ libgdk-3.so.0 ║ ║ libXcomposite.so.1 ║ ║ libXdamage.so.1 ║ ║ libXrandr.so.2 ║ ║ libXtst.so.6 ║ ║ libpangocairo-1.0.so.0 ║ ║ libpango-1.0.so.0 ║ ║ libatk-1.0.so.0 ║ ║ libcairo-gobject.so.2 ║ ║ libcairo.so.2 ║ ║ libgdk_pixbuf-2.0.so.0 ║ ║ libdbus-glib-1.so.2 ║ ║ libxcb-shm.so.0 ║ ║ libX11-xcb.so.1 ║ ║ libXi.so.6 ║ ╚══════════════════════════════════════════════════════╝ browserType.launch: ╔══════════════════════════════════════════════════════╗ ║ Host system is missing dependencies to run browsers. ║ ║ Missing libraries: ║ ║ libsoup-2.4.so.1 ║ ║ libgstreamer-1.0.so.0 ║ ║ libgtk-3.so.0 ║ ║ libgdk-3.so.0 ║ ║ libcairo.so.2 ║ ║ libepoxy.so.0 ║ ║ libevent-2.1.so.7 ║ ║ libopus.so.0 ║ ║ libicui18n.so.66 ║ ║ libicuuc.so.66 ║ ║ libpango-1.0.so.0 ║ ║ libharfbuzz.so.0 ║ ║ libgdk_pixbuf-2.0.so.0 ║ ║ libxslt.so.1 ║ ║ liblcms2.so.2 ║ ║ libwoff2dec.so.1.0.2 ║ ║ libharfbuzz-icu.so.0 ║ ║ libgstallocators-1.0.so.0 ║ ║ libgstapp-1.0.so.0 ║ ║ libgstbase-1.0.so.0 ║ ║ libgstpbutils-1.0.so.0 ║ ║ libgstaudio-1.0.so.0 ║ ║ libgsttag-1.0.so.0 ║ ║ libgstvideo-1.0.so.0 ║ ║ libgstgl-1.0.so.0 ║ ║ libgstfft-1.0.so.0 ║ ║ libjpeg.so.8 ║ ║ libopenjp2.so.7 ║ ║ libwebpdemux.so.2 ║ ║ libwebp.so.6 ║ ║ libenchant-2.so.2 ║ ║ libsecret-1.so.0 ║ ║ libhyphen.so.0 ║ ║ libXcomposite.so.1 ║ ║ libXdamage.so.1 ║ ║ libgbm.so.1 ║ ║ libdrm.so.2 ║ ║ libffi.so.7 ║ ║ libevdev.so.2 ║ ║ libgudev-1.0.so.0 ║ ║ libxkbcommon.so.0 ║ ║ libwayland-server.so.0 ║ ║ libwayland-egl.so.1 ║ ║ libwayland-client.so.0 ║ ║ libGLESv2.so.2 ║ ║ libx264.so ║ ╚══════════════════════════════════════════════════════╝
So, Crafting apt commands
Chromium $ sudo apt install libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libatspi2.0-0 libxcomposite1 libxdamage1 libxrandr2 libgbm1 libxkbcommon0 libpango-1.0-0 libcairo2 Firefox sudo apt install libgtk-3-0 libpangocairo-1.0-0 libcairo-gobject2 libgdk-pixbuf2.0-0 libdbus-glib-1-2 libx11-xcb1 WebKit
still having error
undefined symbol: gbm_bo_get_modifier
Screen Resolution
References
-
Playwright Official - https://playwright.dev/
-
https://zenn.dev/azukiazusa/articles/playwright-component-testing