Skip to content

Instantly share code, notes, and snippets.

@wangshijun
Forked from papoms/fake-referrer.casper.js
Created April 25, 2016 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wangshijun/16011f9098613615100db7f0caac1ddc to your computer and use it in GitHub Desktop.
Save wangshijun/16011f9098613615100db7f0caac1ddc to your computer and use it in GitHub Desktop.
Fake Referrer with CasperJS
var fakeReferrer = "http://porzky.com"
var targetUrl = "http://keyworddomains.com"
var casper = require('casper').create();
casper.start(fakeReferrer, function() {
this.echo(this.getCurrentUrl());
});
casper.then(function(){
this.evaluate(function(){
var link = document.createElement('a');
link.setAttribute('href', 'http://keyworddomains.com');
link.setAttribute('id', "myTargetUrl")
document.body.appendChild(link);
});
});
casper.then(function() {
this.click('a#myTargetUrl');
});
casper.run(function() {
this.echo(this.getCurrentUrl());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment