28

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?

schlingel
  • 8,560
  • 7
  • 34
  • 62
  • One way to simulate headless is to run a browser on a remote Grid, like SauceLabs. That way you don't have to hassle with headless chrome or phantomjs. But, the drawback is that performance is slower and you need the connection outside your network (unless you run your own dockerized Grid hub locally). – djangofan Oct 19 '17 at 16:59

4 Answers4

15

Slimer.js is similar to Phantom.js, but uses Gecko rather than Webkit.

http://slimerjs.org/

Corey Goldberg
  • 59,062
  • 28
  • 129
  • 143
14

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.

schlingel
  • 8,560
  • 7
  • 34
  • 62
9

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.

SDC
  • 14,192
  • 2
  • 35
  • 48
  • The problem isn't selenium, it's Phantom JS (iframe issue). I don't know if Zombie would work, but it isn't an option anyway because I'm using Selenium Grid and need the possibility to insert nodes for e.g. IE testing. – schlingel Feb 26 '13 at 14:56
  • I'm not sure how Zombie can replace phantomjs. With phantomjs installed on a headless ubuntu server, there is a `phantomjs` binary available. Zombie doesn't seem to have a binary, e.g. for use as a selenium driver. I might be completely wrong in my understanding though – Shadi Jul 07 '18 at 02:37
7

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.

mlissner
  • 17,359
  • 18
  • 106
  • 169
teknopaul
  • 6,505
  • 2
  • 30
  • 24