Created
December 14, 2012 17:16
-
-
Save mrluanma/4287072 to your computer and use it in GitHub Desktop.
How to set custom UserAgent in CasperJS.
This file contains hidden or 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 casper = require('casper').create({ | |
verbose: true, | |
logLevel: "info", | |
pageSettings: { | |
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11" | |
} | |
}); | |
casper.start("https://httpbin.org/user-agent", function() { | |
this.test.assertTextExists( | |
'"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11"', | |
'UserAgent header has been correctly setted.'); | |
}); | |
casper.run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment