Phantom js quick start
Upcoming SlideShare
Loading in...5
×
 

Phantom js quick start

on

  • 999 views

 

Statistics

Views

Total Views
999
Views on SlideShare
999
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Phantom js quick start Phantom js quick start Presentation Transcript

  • PhantomJs Quick Start @laserji 2013-12-06 44ux.com
  • WTF • PhantomJS is a headless WebKit scriptable with a JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.
  • WFT • HEADLESS WEBSITE TESTING • SCREEN CAPTURE • PAGE AUTOMATION • NETWORK MONITORING
  • Install • DOWNLOAD && INSTALL
  • Screen Capture 1. var page = require('webpage').create(); 2. page.open('http://wanggou.com', function() { 3. page.render('wanggou.png'); 4. phantom.exit(); 5. });
  • Screen Capture • Capture part of the page 1. page.clipRect = { top: 20, left: 20, width: 200, height: 200}; 2. page.render('wanggou.png');
  • Evaluate Code 1. var page = require('webpage').create(); 2. page.open(url, function(status) { 3. var title = page.evaluate(function() { 4. return document.title; 5. }); 6. console.log('Page title is ' + title); 7. }); 8. From: http://phantomjs.org/quick-start.html
  • Inject Script 1. if(page.injectJs('jquery.js')){ 2. 3. } // use $
  • Command-line Arguments 1. var system = require('system'); 2. var args = system.args; ! 4. if (args.length === 1) { 5. console.log('Try to pass some arguments when invoking this script!'); 6. } else { 7. 8. 9. 10.} args.forEach(function(arg, i) { console.log(i + ': ' + arg); });
  • END • More: http://phantomjs.org/