diff --git a/examples/colorwheel.coffee b/examples/colorwheel.coffee
index b27c7bc1..74866e1f 100644
--- a/examples/colorwheel.coffee
+++ b/examples/colorwheel.coffee
@@ -1,4 +1,4 @@
-page = new WebPage()
+page = require('webpage').create()
page.viewportSize = { width: 400, height : 400 }
page.content = '
'
diff --git a/examples/colorwheel.js b/examples/colorwheel.js
index 55696f07..44fb7bfa 100644
--- a/examples/colorwheel.js
+++ b/examples/colorwheel.js
@@ -1,4 +1,4 @@
-var page = new WebPage;
+var page = require('webpage').create();
page.viewportSize = { width: 400, height : 400 };
page.content = '';
page.evaluate(function() {
diff --git a/examples/direction.coffee b/examples/direction.coffee
index c4e40615..9a2981d7 100644
--- a/examples/direction.coffee
+++ b/examples/direction.coffee
@@ -1,6 +1,6 @@
# Get driving direction using Google Directions API.
-page = new WebPage()
+page = require('webpage').create()
if phantom.args.length < 2
console.log 'Usage: direction.js origin destination'
diff --git a/examples/direction.js b/examples/direction.js
index a2a86906..0476b68e 100644
--- a/examples/direction.js
+++ b/examples/direction.js
@@ -1,6 +1,6 @@
// Get driving direction using Google Directions API.
-var page = new WebPage(),
+var page = require('webpage').create(),
origin, dest, steps;
if (phantom.args.length < 2) {
diff --git a/examples/follow.coffee b/examples/follow.coffee
index efd71be8..5ecf2754 100644
--- a/examples/follow.coffee
+++ b/examples/follow.coffee
@@ -30,7 +30,7 @@ users= [
]
follow = (user, callback) ->
- page = new WebPage()
+ page = require('webpage').create()
page.open 'http://mobile.twitter.com/' + user, (status) ->
if status is 'fail'
console.log user + ': ?'
diff --git a/examples/follow.js b/examples/follow.js
index f25fc3b9..711225ba 100644
--- a/examples/follow.js
+++ b/examples/follow.js
@@ -28,7 +28,7 @@ var users = ['sencha',
'whereisthysting'];
function follow(user, callback) {
- var page = new WebPage();
+ var page = require('webpage').create();
page.open('http://mobile.twitter.com/' + user, function (status) {
if (status === 'fail') {
console.log(user + ': ?');
diff --git a/examples/imagebin.coffee b/examples/imagebin.coffee
index f3130154..93fa6c18 100644
--- a/examples/imagebin.coffee
+++ b/examples/imagebin.coffee
@@ -1,6 +1,6 @@
# Upload an image to imagebin.org
-page = new WebPage()
+page = require('webpage').create()
if phantom.args.length isnt 1
console.log 'Usage: imagebin.coffee filename'
diff --git a/examples/imagebin.js b/examples/imagebin.js
index 090124c9..52b11abe 100644
--- a/examples/imagebin.js
+++ b/examples/imagebin.js
@@ -1,6 +1,7 @@
// Upload an image to imagebin.org
-var page = new WebPage(), fname;
+var page = require('webpage').create(),
+ fname;
if (phantom.args.length !== 1) {
console.log('Usage: imagebin.js filename');
diff --git a/examples/injectme.coffee b/examples/injectme.coffee
index c7450875..15a79890 100644
--- a/examples/injectme.coffee
+++ b/examples/injectme.coffee
@@ -1,7 +1,7 @@
# Use 'page.injectJs()' to load the script itself in the Page context
if phantom?
- page = new WebPage()
+ page = require('webpage').create()
# Route "console.log()" calls from within the Page context to the main
# Phantom context (i.e. current "this")
diff --git a/examples/injectme.js b/examples/injectme.js
index bda55690..d1f21b93 100644
--- a/examples/injectme.js
+++ b/examples/injectme.js
@@ -1,7 +1,7 @@
// Use 'page.injectJs()' to load the script itself in the Page context
if ( typeof(phantom) !== "undefined" ) {
- var page = new WebPage();
+ var page = require('webpage').create();
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page.onConsoleMessage = function(msg) {
diff --git a/examples/loadspeed.coffee b/examples/loadspeed.coffee
index c46e8143..94c68760 100644
--- a/examples/loadspeed.coffee
+++ b/examples/loadspeed.coffee
@@ -1,4 +1,4 @@
-page = new WebPage()
+page = require('webpage').create()
if phantom.args.length is 0
console.log 'Usage: loadspeed.js '
diff --git a/examples/loadspeed.js b/examples/loadspeed.js
index 216ddeb0..0e598b74 100644
--- a/examples/loadspeed.js
+++ b/examples/loadspeed.js
@@ -1,4 +1,4 @@
-var page = new WebPage(),
+var page = require('webpage').create(),
t, address;
if (phantom.args.length === 0) {
diff --git a/examples/netlog.coffee b/examples/netlog.coffee
index a343f145..8ed36839 100644
--- a/examples/netlog.coffee
+++ b/examples/netlog.coffee
@@ -1,4 +1,4 @@
-page = new WebPage()
+page = require('webpage').create()
address = phantom.args[0]
if phantom.args.length is 0
diff --git a/examples/netlog.js b/examples/netlog.js
index 0dd58329..cb8e25e4 100644
--- a/examples/netlog.js
+++ b/examples/netlog.js
@@ -1,4 +1,4 @@
-var page = new WebPage(),
+var page = require('webpage').create(),
address = phantom.args[0];
if (phantom.args.length === 0) {
diff --git a/examples/netsniff.coffee b/examples/netsniff.coffee
index 396a7fd3..184a8ca3 100644
--- a/examples/netsniff.coffee
+++ b/examples/netsniff.coffee
@@ -73,7 +73,7 @@ createHAR = (address, title, startTime, resources) ->
]
entries: entries
-page = new WebPage()
+page = require('webpage').create()
if phantom.args.length is 0
console.log 'Usage: netsniff.js '
diff --git a/examples/netsniff.js b/examples/netsniff.js
index 98330cad..7cd963fc 100644
--- a/examples/netsniff.js
+++ b/examples/netsniff.js
@@ -84,7 +84,7 @@ function createHAR(address, title, startTime, resources)
};
}
-var page = new WebPage();
+var page = require('webpage').create();
if (phantom.args.length === 0) {
console.log('Usage: netsniff.js ');
diff --git a/examples/phantomwebintro.coffee b/examples/phantomwebintro.coffee
index 119fb5ea..0c89ca78 100644
--- a/examples/phantomwebintro.coffee
+++ b/examples/phantomwebintro.coffee
@@ -1,6 +1,6 @@
# Read the Phantom webpage '#intro' element text using jQuery and "includeJs"
-page = new WebPage()
+page = require('webpage').create()
page.onConsoleMessage = (msg) -> console.log msg
diff --git a/examples/phantomwebintro.js b/examples/phantomwebintro.js
index 062a51dd..6bf5a9fc 100644
--- a/examples/phantomwebintro.js
+++ b/examples/phantomwebintro.js
@@ -1,6 +1,6 @@
// Read the Phantom webpage '#intro' element text using jQuery and "includeJs"
-var page = new WebPage();
+var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log(msg);
diff --git a/examples/pizza.coffee b/examples/pizza.coffee
index f9075eef..ac8092d8 100644
--- a/examples/pizza.coffee
+++ b/examples/pizza.coffee
@@ -1,6 +1,6 @@
# Find pizza in Mountain View using Yelp
-page = new WebPage()
+page = require('webpage').create()
url = 'http://lite.yelp.com/search?find_desc=pizza&find_loc=94040&find_submit=Search'
page.open url,
diff --git a/examples/pizza.js b/examples/pizza.js
index e750121a..acdea36a 100644
--- a/examples/pizza.js
+++ b/examples/pizza.js
@@ -1,6 +1,6 @@
// Find pizza in Mountain View using Yelp
-var page = new WebPage(),
+var page = require('webpage').create(),
url = 'http://lite.yelp.com/search?find_desc=pizza&find_loc=94040&find_submit=Search';
page.open(url, function (status) {
diff --git a/examples/post.coffee b/examples/post.coffee
index fc5f38e5..3d75a6ad 100644
--- a/examples/post.coffee
+++ b/examples/post.coffee
@@ -1,6 +1,6 @@
# Example using HTTP POST operation
-page = new WebPage()
+page = require('webpage').create()
server = 'http://posttestserver.com/post.php?dump'
data = 'universe=expanding&answer=42'
diff --git a/examples/post.js b/examples/post.js
index fcdb5623..3868915c 100644
--- a/examples/post.js
+++ b/examples/post.js
@@ -1,6 +1,6 @@
// Example using HTTP POST operation
-var page = new WebPage(),
+var page = require('webpage').create(),
server = 'http://posttestserver.com/post.php?dump',
data = 'universe=expanding&answer=42';
diff --git a/examples/rasterize.coffee b/examples/rasterize.coffee
index 121f0639..1bfdbfc9 100644
--- a/examples/rasterize.coffee
+++ b/examples/rasterize.coffee
@@ -1,4 +1,4 @@
-page = new WebPage()
+page = require('webpage').create()
if phantom.args.length < 2 or phantom.args.length > 3
console.log 'Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat]'
diff --git a/examples/rasterize.js b/examples/rasterize.js
index 04932065..fcd74cdd 100644
--- a/examples/rasterize.js
+++ b/examples/rasterize.js
@@ -1,4 +1,4 @@
-var page = new WebPage(),
+var page = require('webpage').create(),
address, output, size;
if (phantom.args.length < 2 || phantom.args.length > 3) {
diff --git a/examples/render_multi_url.coffee b/examples/render_multi_url.coffee
index a3a37e03..e601ca66 100644
--- a/examples/render_multi_url.coffee
+++ b/examples/render_multi_url.coffee
@@ -11,7 +11,7 @@ Array.prototype.forEach = (action) ->
# @param file File to render to
# @param callback Callback function
renderUrlToFile = (url, file, callback) ->
- page = new WebPage()
+ page = require('webpage').create()
page.viewportSize = { width: 800, height : 600 }
page.settings.userAgent = 'Phantom.js bot'
diff --git a/examples/render_multi_url.js b/examples/render_multi_url.js
index 349c3183..4e28043f 100644
--- a/examples/render_multi_url.js
+++ b/examples/render_multi_url.js
@@ -16,7 +16,7 @@ Array.prototype.forEach = function (action) {
* @param callback Callback function
*/
function renderUrlToFile(url, file, callback) {
- var page = new WebPage();
+ var page = require('webpage').create();
page.viewportSize = { width: 800, height : 600 };
page.settings.userAgent = "Phantom.js bot";
diff --git a/examples/run-jasmine.coffee b/examples/run-jasmine.coffee
index 999b3836..3b628c49 100644
--- a/examples/run-jasmine.coffee
+++ b/examples/run-jasmine.coffee
@@ -33,7 +33,7 @@ if phantom.args.length isnt 1
console.log 'Usage: run-jasmine.coffee URL'
phantom.exit()
-page = new WebPage()
+page = require('webpage').create()
# Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page.onConsoleMessage = (msg) ->
diff --git a/examples/run-jasmine.js b/examples/run-jasmine.js
index 1a26a8a0..f26b9b54 100644
--- a/examples/run-jasmine.js
+++ b/examples/run-jasmine.js
@@ -39,7 +39,7 @@ if (phantom.args.length === 0 || phantom.args.length > 2) {
phantom.exit();
}
-var page = new WebPage();
+var page = require('webpage').create();
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page.onConsoleMessage = function(msg) {
diff --git a/examples/run-qunit.coffee b/examples/run-qunit.coffee
index f9eceb3f..59534c57 100644
--- a/examples/run-qunit.coffee
+++ b/examples/run-qunit.coffee
@@ -33,7 +33,7 @@ if phantom.args.length isnt 1
console.log 'Usage: run-qunit.coffee URL'
phantom.exit(1)
-page = new WebPage()
+page = require('webpage').create()
# Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page.onConsoleMessage = (msg) ->
diff --git a/examples/run-qunit.js b/examples/run-qunit.js
index 8172f03a..54c1d5dd 100644
--- a/examples/run-qunit.js
+++ b/examples/run-qunit.js
@@ -39,7 +39,7 @@ if (phantom.args.length === 0 || phantom.args.length > 2) {
phantom.exit(1);
}
-var page = new WebPage();
+var page = require('webpage').create();
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page.onConsoleMessage = function(msg) {
diff --git a/examples/technews.coffee b/examples/technews.coffee
index 0e2c7806..7a9807eb 100644
--- a/examples/technews.coffee
+++ b/examples/technews.coffee
@@ -1,4 +1,4 @@
-page = new WebPage()
+page = require('webpage').create()
page.viewportSize = { width: 320, height: 480 }
diff --git a/examples/technews.js b/examples/technews.js
index 5db9890c..ba7cd94e 100644
--- a/examples/technews.js
+++ b/examples/technews.js
@@ -1,4 +1,4 @@
-var page = new WebPage();
+var page = require('webpage').create();
page.viewportSize = { width: 320, height: 480 };
page.open('http://news.google.com/news/i/section?&topic=t', function (status) {
if (status !== 'success') {
diff --git a/examples/tweets.coffee b/examples/tweets.coffee
index 37a335f1..1df63bc8 100644
--- a/examples/tweets.coffee
+++ b/examples/tweets.coffee
@@ -1,6 +1,6 @@
# Get twitter status for given account (or for the default one, "sencha")
-page = new WebPage()
+page = require('webpage').create()
twitterId = 'sencha' #< default value
# Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
diff --git a/examples/tweets.js b/examples/tweets.js
index c8a728f1..fd5454c2 100644
--- a/examples/tweets.js
+++ b/examples/tweets.js
@@ -1,6 +1,6 @@
// Get twitter status for given account (or for the default one, "sencha")
-var page = new WebPage(),
+var page = require('webpage').create(),
twitterId = "sencha"; //< default value
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
diff --git a/examples/unrandomize.coffee b/examples/unrandomize.coffee
index 877035c1..841ffc73 100644
--- a/examples/unrandomize.coffee
+++ b/examples/unrandomize.coffee
@@ -1,7 +1,7 @@
# Modify global object at the page initialization.
# In this example, effectively Math.random() always returns 0.42.
-page = new WebPage()
+page = require('webpage').create()
page.onInitialized = ->
page.evaluate ->
Math.random = ->
diff --git a/examples/unrandomize.js b/examples/unrandomize.js
index b1bcab25..2aa2f818 100644
--- a/examples/unrandomize.js
+++ b/examples/unrandomize.js
@@ -1,7 +1,7 @@
// Modify global object at the page initialization.
// In this example, effectively Math.random() always returns 0.42.
-var page = new WebPage();
+var page = require('webpage').create();
page.onInitialized = function () {
page.evaluate(function () {
diff --git a/examples/useragent.coffee b/examples/useragent.coffee
index f492d6e1..d401c7f5 100644
--- a/examples/useragent.coffee
+++ b/examples/useragent.coffee
@@ -1,4 +1,4 @@
-page = new WebPage()
+page = require('webpage').create()
console.log 'The default user agent is ' + page.settings.userAgent
diff --git a/examples/useragent.js b/examples/useragent.js
index 8761a734..60f537e1 100644
--- a/examples/useragent.js
+++ b/examples/useragent.js
@@ -1,4 +1,4 @@
-var page = new WebPage();
+var page = require('webpage').create();
console.log('The default user agent is ' + page.settings.userAgent);
page.settings.userAgent = 'SpecialAgent';
page.open('http://www.httpuseragent.org', function (status) {
diff --git a/examples/waitfor.coffee b/examples/waitfor.coffee
index 94e86485..fb2b767d 100644
--- a/examples/waitfor.coffee
+++ b/examples/waitfor.coffee
@@ -30,7 +30,7 @@ waitFor = (testFx, onReady, timeOutMillis=3000) ->
interval = setInterval f, 250 #< repeat check every 250ms
-page = new WebPage()
+page = require('webpage').create()
# Open Twitter on 'sencha' profile and, onPageLoad, do...
page.open 'http://twitter.com/#!/sencha', (status) ->
diff --git a/examples/waitfor.js b/examples/waitfor.js
index 2baa18b1..6c5ecb80 100644
--- a/examples/waitfor.js
+++ b/examples/waitfor.js
@@ -34,7 +34,7 @@ function waitFor(testFx, onReady, timeOutMillis) {
};
-var page = new WebPage();
+var page = require('webpage').create();
// Open Twitter on 'sencha' profile and, onPageLoad, do...
page.open("http://twitter.com/#!/sencha", function (status) {
diff --git a/examples/weather.coffee b/examples/weather.coffee
index b77f84b4..f7a3320e 100644
--- a/examples/weather.coffee
+++ b/examples/weather.coffee
@@ -1,6 +1,6 @@
# Get weather info for given address (or for the default one, "Mountain View")
-page = new WebPage()
+page = require('webpage').create()
address = 'Mountain View' #< default value
# Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
diff --git a/examples/weather.js b/examples/weather.js
index 4864785f..9bcb341e 100644
--- a/examples/weather.js
+++ b/examples/weather.js
@@ -1,6 +1,6 @@
// Get weather info for given address (or for the default one, "Mountain View")
-var page = new WebPage(),
+var page = require('webpage').create(),
address = "Mountain View"; //< default value
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")