tmegos blog

Web developer

WebdriverIO

github.com

作業ログです

wdio configが便利

$ npx wdio config

=========================
WDIO Configuration Helper
=========================

? Where is your automation backend located? On my local machine
? Which framework do you want to use? mocha
? Do you want to run WebdriverIO commands synchronous or asynchronous? sync
? Where are your test specs located? top.spec.ts
? Do you want WebdriverIO to autogenerate some test files? Yes
? Do you want to use page objects (https://martinfowler.com/bliki/PageObject.html)? No
? Are you using a compiler? TypeScript (https://www.typescriptlang.org/)
? Which reporter do you want to use? spec
? Do you want to add a service to your test setup? chromedriver
? What is the base url? http://localhost:8080
  • ページオブジェクトパターン使う?って聞いてくるくらいなので、使うのが推奨なのかもしれない
  • ブラウザのドライバをいろいろ選べる

tsconfig.jsonは作ってくれない

Packages installed successfully, creating configuration file...

Config file installed successfully, creating test files...
To have TypeScript support please add the following packages to your "types" list:
{
  "compilerOptions": {
    "types": ["node", "@wdio/sync", "@wdio/mocha-framework"]
  }
}

For for information on TypeScript integration check out: https://webdriver.io/docs/typescript.html


Configuration file was created successfully!

何も考えずにテスト書いたら、ログイン後にasyncで2秒待つところで落ちた
SPAと相性が悪いのかな

ドキュメントの誤りを見つけたのでPR出した

https://github.com/megos/spa-e2e-sandbox/runs/1715952497?check_suite_focus=true

github.com

GitHub Actions ミステイク

いつもどおりubuntu-latestで動かす

Add GitHub Actions · megos/spa-e2e-sandbox@8934fa0 · GitHub

ERROR webdriver: Request failed with status 500 due to unknown error: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
testを実行するときだけianwalter/puppeteer@mainを使う

Add GitHub Actions · megos/spa-e2e-sandbox@215bc95 · GitHub

さっきと同じエラー

headlessオプション設定ミス

Add headless option · megos/spa-e2e-sandbox@0d946d5 · GitHub

headlessで動かす

stackoverflow.com

Add headless option · megos/spa-e2e-sandbox@2c7601f · GitHub

--no-sandboxをつけた

qiita.com

Add no-sandbox option · megos/spa-e2e-sandbox@921328b · GitHub

Starting ChromeDriver 87.0.4280.20 (c99e81631faa0b2a448e658c0dbd8311fb04ddbd-refs/branch-heads/4280@{#355}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
[1610866697.868][SEVERE]: bind() failed: Cannot assign requested address (99)
--allowed-ipsつけた

chromedriver.chromium.org

Fix bind() failed: Cannot assign requested address (99) · megos/spa-e2e-sandbox@781d32f · GitHub

npm installもianwalter/puppeteer@mainを使ってみる

アプリが立ち上がらない

Mod · megos/spa-e2e-sandbox@1360604 · GitHub Mod · megos/spa-e2e-sandbox@c7ac022 · GitHub Mod · megos/spa-e2e-sandbox@197c899 · GitHub

$ snowpack dev
/home/runner/work/spa-e2e-sandbox/spa-e2e-sandbox/node_modules/snowpack/lib/index.js:69474
    path_1.default.join(util$j.GLOBAL_CACHE_DIR, crypto_1.default.createHash('md5').update(process.cwd()).digest('hex'));
                               ^

TypeError: Cannot read property 'GLOBAL_CACHE_DIR' of undefined

GitHub Actionsと格闘して1時間たっても解決しないので心が折れた