Created
July 4, 2012 08:46
-
-
Save n1k0/3046142 to your computer and use it in GitHub Desktop.
PhantomJS test script for window.location
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var page = require('webpage').create(); | |
var base = phantom.args[0]; | |
var path = phantom.args[1]; | |
var expected = phantom.args[2]; | |
page.onNavigationRequested = function(url, navigationType, navigationLocked, isMainFrame) { | |
console.log('Navigation requested: ' + navigationType + '; ' + url); | |
if (!page.testStarted) { | |
return; | |
} | |
if (url === expected) { | |
console.log('PASS'); | |
phantom.exit(); | |
} | |
}; | |
page.open(base, function(status) { | |
page.testStarted = true; | |
console.log('window.location = ' + path); | |
page.evaluate(function(path) { | |
window.location = path; | |
}, path); | |
}); | |
setTimeout(function() { | |
console.log('FAIL: navigation to ' + path + ' never happened'); | |
phantom.exit(1); | |
}, 5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, just tried with PhantomJS 1.9.7 (with google.com and github.com), and it indeed doesn't work. Do you have an idea how to get around this?