Skip to content
This repository
tree: fafa01d6ba
file 17 lines (15 sloc) 0.468 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# Modify global object at the page initialization.
# In this example, effectively Math.random() always returns 0.42.

page = require('webpage').create()
page.onInitialized = ->
  page.evaluate ->
    Math.random = ->
      42 / 100

page.open "http://ariya.github.com/js/random/", (status) ->
  if status != "success"
    console.log "Network error."
  else
    console.log page.evaluate(->
      document.getElementById("numbers").textContent
    )
  phantom.exit()
Something went wrong with that request. Please try again.