Your SlideShare is downloading. ×
0
Phantom js quick start
Phantom js quick start
Phantom js quick start
Phantom js quick start
Phantom js quick start
Phantom js quick start
Phantom js quick start
Phantom js quick start
Phantom js quick start
Phantom js quick start
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Phantom js quick start

1,032

Published on

Published in: Technology, Art & Photos
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,032
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. PhantomJs Quick Start @laserji 2013-12-06 44ux.com
  • 2. 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.
  • 3. WFT • HEADLESS WEBSITE TESTING • SCREEN CAPTURE • PAGE AUTOMATION • NETWORK MONITORING
  • 4. Install • DOWNLOAD && INSTALL
  • 5. Screen Capture 1. var page = require('webpage').create(); 2. page.open('http://wanggou.com', function() { 3. page.render('wanggou.png'); 4. phantom.exit(); 5. });
  • 6. Screen Capture • Capture part of the page 1. page.clipRect = { top: 20, left: 20, width: 200, height: 200}; 2. page.render('wanggou.png');
  • 7. 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
  • 8. Inject Script 1. if(page.injectJs('jquery.js')){ 2. 3. } // use $
  • 9. 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); });
  • 10. END • More: http://phantomjs.org/

×