Skip to content

Instantly share code, notes, and snippets.

@jeisc
Forked from n1k0/location.js
Created January 22, 2013 08:16
Show Gist options
  • Select an option

  • Save jeisc/4592974 to your computer and use it in GitHub Desktop.

Select an option

Save jeisc/4592974 to your computer and use it in GitHub Desktop.
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