Phantom JS是一個服務器端的 JavaScript API 的 WebKit。其支持各種Web標準: DOM 處理, CSS 選擇器, JSON, Canvas, 和 SVG
使用場景:
- 無需瀏覽器的 Web 測試
- 頁面訪問自動化
- 屏幕捕獲
- 網絡監控
- 屏幕捕獲示例代碼:
#
var page = require(‘webpage’).create();
page.open(‘http://github.com/‘, function() { page.render(‘github.png’);
phantom.exit();});
PhantomJS 生態環境:
#
- CasperJS enables easy navigation scripting and common high-level testing.
- Poltergeist allows running Capybara tests headlessly.
- Guard::Jasmine automatically tests Jasmine specs on Rails when files are modified.
- GhostDriver complements Selenium tests with a PhantomJS WebDriver implementation.
- PhantomRobot runs Robot Framework acceptance tests in the background via PhantomJS.
- Mocha-PhantomJS run Mocha tests using PhantomJS.
#
其他一些相關項目。