Reputation: 8575
I'm currently trying to build a little testing suite for CI (Hudson). I've written a complex script which dynamically invokes other Scripts and populates a given DIV element.
My Selenium tests work for trivial examples (load www.google.com, search for the q-Element, etc.)
But when I try to run a complex test, which works with the Firefox-Driver, in my PhantomJS instance, it crashes. A segfault occurs.
My question is, how can I write tests for my frontend JS which works on a Hudson-Server which runs (headless).
Or is there a way of debugging what causes segfault?
Upvotes: 28
Views: 37716
Reputation: 6780
jsdom is a good alternative now, its quite mature.
https://github.com/tmpvar/jsdom/
Its for headless testing. I don't think it will do screen shots like phantomjs did since it has no webkit or gekko renderer its pure JS.
I found this since phantomjs segfaults and the new version will not build. slimerjs is not really headless, and its XULRunner based which FireFox just dropped, it does not work with my current FF.
jsdom is pretty cool, it started life as an XML parser and now has a full network backend and jQuery support.
API is not the same as phantomjs.
Upvotes: 7
Reputation: 60654
Slimer.js is similar to Phantom.js, but uses Gecko rather than Webkit.
Upvotes: 15
Reputation: 14212
Phantom is an evolving product, and only relatively recently gained the ability to integrate with Selenium, so you may have hit a bug with it; have you tried reporting it to the Phantom devs?
Alternatives to Phantom:
There aren't many. Zombie is one that I know of, but Phantom is head and shoulders above any other headless browser.
You could also try using a headless virtual server to run any of the normal web browsers. (this would also have the advantage of being a more real-life test than Phantom)
Alternatives to Selenium:
You could use Sahi as a direct replacement to Selenium. It's capable of much the same things, but works quite differently. Your test scripts would need to be rewritten, of course.
Phantom is designed to be scripted, so you don't actually need to use a driver tool like Selenium at all for it; you could just script it directly, or use a tool like CasperJS to write your test scripts.
Upvotes: 9
Reputation: 8575
Headless installations are possible when using Xvfb as virtual frame buffer (on Linux machines hosting the grid nodes). Ended up using this and the default Firefox.
Upvotes: 14