1 // Modify global object at the page initialization.
2 // In this example, effectively Math.random() always returns 0.42.
4 var page = require('webpage').create();
6 page.onInitialized = function () {
7 page.evaluate(function () {
8 Math.random = function() {
14 page.open('http://ariya.github.com/js/random/', function (status) {
16 if (status !== 'success') {
17 console.log('Network error.');
19 console.log(page.evaluate(function () {
20 return document.getElementById('numbers').textContent;