Puppeteer是一個node庫,他提供了一組用來操縱Chrome的API(默認headless也就是無UI的chrome,也能夠配置爲有UI)
Puppeteer(中文翻譯」木偶」) 是 Google Chrome 團隊官方的無界面(無頭或無腦Headless)Chrome 工具,它是一個
Node 庫,提供了一個高級的 API 來控制 DevTools協議上的無頭版 Chrome 。也能夠配置爲使用完整(非無頭)的 Chrome。Chrome 素來在瀏覽器界穩執牛耳,所以,Chrome Headless 必將成爲 web 應用自動化測試的行業標杆。使用 Puppeteer,至關於同時具備 Linux 和 Chrome 雙端的操做能力,應用場景可謂很是之多。此倉庫的創建,便是嘗試各類折騰使用 GoogleChrome Puppeteer;以期在好玩的同時,學到更多有意思的操做。
做用和Selenium類似,可是不能跨平臺,只能用在chrome作自動化測試
官網:
大綱:
- Installation
- Usage
- Default runtime settings
- API Documentation
- Debugging tips
- FAQ
Q: What is the difference between Puppeteer, Selenium / WebDriver, and PhantomJS?
Selenium / WebDriver is a well-established cross-browser API that is useful for testing cross-browser support.
Puppeteer works only with Chromium or Chrome. However, many teams only run unit tests with a single browser (e.g. PhantomJS). In non-testing use cases, Puppeteer provides a powerful but simple API because it's only targeting one browser that enables you to rapidly develop automation scripts.
Puppeteer bundles the latest versions of Chromium.
Q: Why is the Chrome team building Puppeteer?
The goals of the project are simple:
- Provide a slim, canonical library that highlights the capabilities of the DevTools Protocol.
- Provide a reference implementation for similar testing libraries. Eventually, these other frameworks could adopt Puppeteer as their foundational layer.
- Grow the adoption of headless/automated browser testing.
- Help dogfood new DevTools Protocol features...and catch bugs!
- Learn more about the pain points of automated browser testing and help fill those gaps.