What are the pros and cons in using PhantomJS natively instead of Chrome through webdriver for QA functional testing?

Nalin picture Nalin · Apr 3, 2015 · Viewed 8.3k times · Source

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.

Answer

Saifur picture Saifur · Apr 3, 2015

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.