PhantomJS and JS Test Driver

208 views
Skip to first unread message

Ivan De Marino

unread,
Apr 7, 2011, 10:06:53 AM4/7/11
to phan...@googlegroups.com
Hello.

I finally got the time to come back to PhantomJS.
I have been planning for weeks to use it as a Test Browser for JS Test Driver (http://code.google.com/p/js-test-driver/).

I had some emails with Ariya, and he thinks I should do this making a simple script that accepts a URL from the command line and does a "phantom.open" call.

That's my script so far:
if (phantom.args.length === 0) {
    console.log("This example instruct PhantomJS to just open a specific URL.")
    console.log('URL must be passed as a parameter.');
    phantom.exit();
} else {
    if (phantom.state.length === 0) {
        console.log("Loading: " + phantom.args[0]);
        phantom.state = 'gotourl';
        phantom.open(phantom.args[0]);
    } else {
        console.log("Loaded!");
        // TODO - I don't have a specific condition for exit yet
    }
}

Well, it doesn't work.
JS Test Driver seems to hang there, doing nothing.

I'm doing some debugging, from the inside and the outside of phantomjs, but I'm curious to know if any of you ever tried to use JS Test Driver with PhantomJS.


Ivan De Marino

unread,
Apr 7, 2011, 10:29:33 AM4/7/11
to phan...@googlegroups.com
Well, I can pretty confidently say that there is something wrong with the handling of HTTP 302.
I can't get phantomjs to load the content of "http://localhost:9876/capture".

I'll keep investigating...

Ariya Hidayat

unread,
Apr 7, 2011, 2:38:44 PM4/7/11
to phan...@googlegroups.com, Ivan De Marino
> I finally got the time to come back to PhantomJS.
> I have been planning for weeks to use it as a Test Browser for JS Test
> Driver (http://code.google.com/p/js-test-driver/).

Is there an issue associated with this? If not, would be a good idea
to create it first.

In all cases, this would be really good to have.

--
Ariya Hidayat
http://www.linkedin.com/in/ariyahidayat

Ivan De Marino

unread,
Apr 7, 2011, 4:10:30 PM4/7/11
to phan...@googlegroups.com, Ivan De Marino
Before I raise a bug I need to be sure.

I'm taking it apart: I'll add a custom QNetworkAccessManager to help my investigation.
Maybe it could be good to keep it there after my investigation: what do you think? ;)

Ariya Hidayat

unread,
Apr 7, 2011, 4:53:56 PM4/7/11
to phan...@googlegroups.com, Ivan De Marino

Custom network access manager would be useful for
http://code.google.com/p/phantomjs/issues/detail?id=2.

Ivan De Marino

unread,
Apr 7, 2011, 5:13:27 PM4/7/11
to Ariya Hidayat, phan...@googlegroups.com
Great!
Than, I'll do it even more.

Btw, phantomjs.cpp is getting too crowded: I'm splitting stuff into headers and cpp.
Just adding NetworkAccessManager within the same file would get ridiculous...
Reply all
Reply to author
Forward
0 new messages