6
votes

We are testing a very browser dependent/coupled(chrome) single page application with selenium webdriver for Chrome. Some suggest to use PhantomJS for its speed, because it is headless.

This web application is also a JavaScript-heavy thick client. I want to know any advantages or disadvantages in using PhantomJS for this purpose.

3
You mean Chrome vs. PhantomJS both through webdriver and not Chrome (Webdriver) vs. PhantomJS (native), right?Artjom B.
Actually it is about Chrome (Webdriver) vs. PhantomJS (native) approach.Nalin

3 Answers

3
votes

My opinion is PhantomJS is not really mature for a large scale project.

I have used ChromeDriver, IE very extensively for a quite large payroll application. I have explored PhantomJS for some of the testing and exploring its benefit.

Pros and cons of using PhantomJS instead of real browsers

Pros:

  • Lot of people use PhantomJS because it's headless and to avoid additional overhead with real browser.

  • You can run the tests on CI directly using this and avoid Grid Hub relationship(or other similar mechanism) which is sometimes little messy to handle

Cons:

  • There are a significant number of pending issues in PhantomJS

  • While e2e and UI testing are mostly used to replicate the user behaviour, PhantomJs does not exactly do that

  • There are few cases where PhantomJS fails but other drivers work perfectly.

  • Protractor team directly discourage you to use PhantomJS if you are planning to do so.

2
votes

If you're as coupled with Chrome as you say you are, you should run Chrome.

PhantomJS no longer runs the same rendering engine as Chrome since Blink was released, so running tests from PhantomJS will not provide an accurate representation of how your website will perform on Chrome (it may work the same, but there may be slight differences).

Also, PhantomJS may run on Webkit, but it is a very old version of Webkit.

Bottom line: Blink =/= Webkit. Go with Chrome.

0
votes

PhantomJS has many pending issues and lack of active development on the project makes the situation even more difficult. Many website do not load on PhantomJS.

You can try Chrome Headless. https://developers.google.com/web/updates/2017/04/headless-chrome

You can get the headless nature of PhantonJS and mainstream-ness of Chrome. Best of both worlds.