LoginSignup
52
41

More than 3 years have passed since last update.

2020年: PuppeteerとPlaywrightの激動の1年。

Last updated at Posted at 2020-12-20

2020年は、突如Playwrightが現れ、Seleniumを置き換えるほどの勢いでいろいろなツールが現れました。
Puppeteerは、Playwrightが出てからもTypeScript化をしたりカスタムクエリハンドラ機能が実装されたりと、Chrome DevToolsプロトコルを利用するライブラリとして改善が続いています。

今年1年の

を時系列にまとめてみます。

2020年1月。

PuppeteerとPlaywrightの15日間の演劇
https://speakerdeck.com/taminif/relation-of-puppeteer-and-playwright
に非常にわかりやすくまとめられていますw

Playwright 爆誕

コミットログを見ると、2019年秋ごろからずっと開発されていたようですが、1月末に突如公開されたようです。
PuppeteerをもともとGoogleで開発してた人が、マイクロソフトで「さらに、いろんなブラウザで使えるように」(かなり意訳w)と開発した旨がREADMEに記載していた。

We are the same team that originally built Puppeteer at Google, but has since then moved on. Puppeteer proved that there is a lot of interest in the new generation of ever-green, capable and reliable automation drivers. With Playwright, we'd like to take it one step further and offer the same functionality for all the popular rendering engines. We'd like to see Playwright vendor-neutral and shared governed.


https://github.com/microsoft/playwright/pull/711/files

Puppeteer v2.1: Firefoxに正式対応した!

もともと puppeteer-firefoxというライブラリはありましたが、これはFirefox側にも魔改造を入れたものでないと動かない代物でした。
魔改造FirefoxはJugglerという名前で、リポジトリも別にあります。(おそらくもうメンテナンスされていません)
https://github.com/puppeteer/juggler

ところが、Puppeteer 2.1からは、とくに魔改造されていない、素のFirefox Nightlyビルドに対して、CDPでそのまま自動操作できるようになりました。

(ただ、2020年12月現在でもなお、絵文字入力ができないなど制限事項が結構たくさんあります。 詳しくはこの記事にまとめました)

2020年2月。

Playwright v0.11

品質強化が続きます。

Puppeteer v2.1.1

こちらも細かいバグ修正が多いです。
この頃から、TypeScript移行に向けた動きが出てき始めます。

2020年3月

Playwright v0.12

かなり破壊的変更がありました。もともとPuppeteer由来のメソッドやクラスが多かったものが、Playwrightらしくなった第一歩でもあります。
https://github.com/microsoft/playwright/releases/tag/v0.12.0

リリースノートの1行目にある

There is no extra window when launching in headful mode.

これが地味に良い改善で、Puppeteerは2020年12月現在も、 browser.newPage() を単純に呼ぶと2つのウインドウが出ます。特段に害はないのですが、なんか邪魔くさいです。
いっぽうで、Playwrightは1つしか出ません。

puppeteer playwright
puppeteer playwright

2020年4月

Playwright v0.13

ややこしいファイルダウンロードまわりが、いち早くAPI化されてPlaywrightで利用可能になりました。(Puppeteerは2020年12月現在もこの機能はありません)
Puppeteerから分岐して、順調に独自路線を歩み始めています。

Puppeteer v3.0.0

一方で、Puppeteerは4/2に、いきなり、libディレクトリがsrcディレクトリに変更になりました。
https://github.com/puppeteer/puppeteer/pull/5568

その2週間後くらいに、TypeScript移行を表明した Puppeteer 3.0がリリースされました。
https://github.com/puppeteer/puppeteer/releases/tag/v3.0.0

この時点では、まだソースコードは(ごく一部を除き)JSでした。
https://github.com/puppeteer/puppeteer/tree/v3.0.0/src

Puppeteer v3.0.1

3.0.0のリリースから1週間、少しだけTypeScript化された3.0.1がリリース。
https://github.com/puppeteer/puppeteer/releases/tag/v3.0.1

1週間前までは全部JSだったsrcが、一部TSになってるのがわかります。
https://github.com/puppeteer/puppeteer/tree/v3.0.1/src

Puppeteer v3.0.2

3.0.1のリリースからさらに1週間、さらにまた少しだけTypeScript化された3.0.2がリリース。
https://github.com/puppeteer/puppeteer/releases/tag/v3.0.2

1週間前より、さらにいくつか.tsになりました。
https://github.com/puppeteer/puppeteer/tree/v3.0.2/src

Playwright v0.14, v0.15

このバージョンから、elementHandleに innerHTML, textContent, など、便利メソッドが生えています。
Puppeteerだと、 .evaluate(el => el.textContent) などいちいちevaluateしないといけないやつです。(このあたりは好き嫌いの問題かなとも思います。)

0.14からほとんど間もない間に、0.15がリリースされました。

2020年5月。

Playwright v0.16, v0.17, v0.18, v1.0.0, v1.0.1, v1.0.2: 正式リリース :tada:

https://github.com/microsoft/playwright/releases/tag/v0.16.0
https://github.com/microsoft/playwright/releases/tag/v0.17.0
https://github.com/microsoft/playwright/releases/tag/v0.18.0
https://github.com/microsoft/playwright/releases/tag/v1.0.0
https://github.com/microsoft/playwright/releases/tag/v1.0.1
https://github.com/microsoft/playwright/releases/tag/v1.0.2

このあたりは、Playwright 1.0リリースに向けて、かなり多くのバグフィックスがされて細かくリリースされています。

Playwrightは1.0リリースから、概ね1ヶ月間隔でのアップデートとなっています。

Puppeteer v3.0.3: TypeScript化 + カスタムクエリハンドラがexperimentalで追加

いっぽうのPuppeteerも、v3.0.2リリースからさらに1週間、TypeScriptになったPuppeteerがリリース。
https://github.com/puppeteer/puppeteer/releases/tag/v3.0.3

すべてのソースコードが確かに.tsになりました。
https://github.com/puppeteer/puppeteer/tree/v3.0.3/src

また、リリースノートにはしれっとかいてありますが、カスタムクエリハンドラ(registerCustomQueryHandler)の実装がexperimentalで利用可能になりました。
https://github.com/puppeteer/puppeteer/pull/5753

Puppeteer v3.1.0

SANのAPIが追加になっています(が、私は使ったことがないのでよくわかりません...w)
TypeScript化したあとの、細かいリファクタリングや開発環境改善が多いです。

Puppteer v3.2.0

NodeのEventEmitterを使っていたところを、Mittというライブラリに置き換えられました。
(が、これはあまりに大きなBreaking Changeだったようで、数日後に、Revertされましたw)

2020年6月。

Puppeteer v3.3.0

The migration from Node's EventEmitter to the Mitt library has been reverted in this release. We're sorry for causing unexpected issues in the 3.2.0 release. If you were unable to upgrade from 3.1.0 to 3.2.0, you will be able to upgrade straight to 3.3.0 and not have any issues.

まさにこのとおり。MittがNodeのEventEmitterに戻りました。

Playwright v1.1

https://github.com/microsoft/playwright/releases/tag/v1.1.0
https://github.com/microsoft/playwright/releases/tag/v1.1.1

ElementHandleだけでなく、Pageも .textContentや.innerHTMLできるようになりました。

Puppeteer v4.0

でも結局PuppeteerのEventEmitterはMittに置き換えられましたw
https://github.com/puppeteer/puppeteer/releases/tag/v4.0.0

メジャーバージョンが変われば、破壊的変更があってもよかろう、ということなんでしょうね。

あと、地味に良い変更が1つ入っていて、Ctrl+Cでぶちっとセッションを切ったときの後始末が、しっかり行われるようになっています。
https://github.com/puppeteer/puppeteer/pull/6011

2020年7月。

Puppeteer v5.0

v4.0のリリースからわずか1ヶ月、Puppeteerはv5.0になりました。

ここには特筆すべき表明が1つ書いてあって、

We've started restructuring Puppeteer to work towards being able to better support an environment agnostic Puppeteer module. You can track this work in #6125.

environment agnostic Puppeteer module にしていくために、構造を少しずつ変えていきますよ、と。
https://github.com/puppeteer/puppeteer/issues/6125

Playwright v1.2: Playwrightがデバッグコンソールで利用可能に!

(動画は公式ページから拝借)
devtool

あとは、Dockerイメージが公開されたらしい。(けど、使う・・・? CIとか用かな?)

2020年8月。

Playwright v1.3: Playwright Python爆誕

JSだけでなく、Python用のPlaywrightが爆誕。
https://github.com/microsoft/playwright-python

2020年9月。

Playwright v1.4: playwright-cli(コードジェネレータ)爆誕

2020年10月。

Playwright v1.5: コードジェネレータがPythonにも対応 && 動画録画機能が正式化 && playwright-test爆誕

Puppeteer v5.4: カスタムクエリハンドラーの正式化

puppeteer.registerCustomQueryHandler(name: string, queryHandler: CustomQueryHandler): void;
puppeteer.unregisterCustomQueryHandler(name: string): void;
puppeteer.customQueryHandlerNames(): string[];
puppeteer.clearCustomQueryHandlers(): void;

2020年11月

Playwright v1.6: コードジェネレータがC#にも対応

2020年12月

Playwright v1.7: playwright-java爆誕

C#, Pythonにつづき、なんとJavaにも対応しました。
https://github.com/microsoft/playwright-java

macOSのBigSur対応・M1チップ対応もこのバージョンに入っています。
※ Playwrightは、macOSのバージョンを細かく分岐しているイマイチな作りゆえ、バージョンが少しでも上がると動きません。(以下のPRで言及されています)
https://github.com/microsoft/playwright/pull/4724

まとめ

2020年後半の、Playwrightの進化は本当にめざましいです。毎月のように大物機能がリリースされました。
とはいえ、Puppeteerも純粋にDevTools Protocolを使ったシンプルなツールとして着々と改善されていますし、どっちが良い悪いとかではなく、それぞれが必要に応じた進化をしていると思います。

来年はどうなることでしょう。それでは良いお年を!

52
41
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
52
41