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