Created
June 24, 2013 12:03
-
-
Save thecodejunkie/5849584 to your computer and use it in GitHub Desktop.
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 page = require('webpage').create(); | |
var system = require('system'); | |
var address; | |
address = system.args[1]; | |
console.log(address); | |
page.open(address, function(status) { | |
console.log(status); | |
}); | |
console.log('Done'); | |
phantom.exit(); |
It looks like it works if I move the phantom.exit()
to inside the callback that is passed to open
. I was just putting it outside since the PhantomJS docs only said
"It is very important to call phantom.exit at some point in the script, otherwise PhantomJS will not be terminated at all."
Lol - yes sorry ,obvious thing - if you call it at the end it'll be called before the page is opened and you'll never get the callback
My tests tend to do
before(function(done) {
setupPhantom(done)
})
after(function(done) {
closePhantom()
})
Oooh, hehe yeah that make sense. Cheers!
I've not gotten that far.. literally using it for the first time today and I'm following their "Getting Started" section before I dig any deeper :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If the file doesn't finish loading you'll not get anything I've found - the code you have is valid though.
I never use PhantomJS in this way, I spawn it up on the command line and interact with it via WebDriver, it's hella lot more stable that way.