Phantomjs Interview Questions

Phantomjs Interview Questions

1) What is Phantomjs?

PhantomJS is known as a web browser without a graphical user interface. PhantomJS is a headless WebKit and web browser scriptable with a JavaScript API. Its native support for various web standards such as DOM handling, CSS selector, JSON, Canvas, and SVG provides fast performance. It works with Windows, macOS, Linux, and FreeBSD.

2) Enlist some difference between puppeteer and phantomjs?

PhantomJS is a headless WebKit scriptable with JavaScript which is used for web-related development workflow. Whereas Puppeteer is detailed as "Headless Chrome Node API". Basically, it is a Node library that provides a high-level API to control headless Chrome over the DevTools Protocol which can also be configured to use full (non-headless) Chrome.

3) List major features of Phantomjs?

The major features of Phantomjs are listed below:

  1. Page Automation
  2. Screen Capture
  3. Headless Testing
  4. Network Monitoring
  5. Ability to monitor the network connection

4) What is Headless Testing?

Headless testing is a testing process that is simply running your Selenium tests using a headless browser. IT is automated testing because It operates like your typical browser would, but without a user interface. It can create new testing opportunities as well as accelerate tests that have already running. It has the benefits of Greater testing reach, Multitasking, Improved speed, and performance.

5) What objects are available in Phantomjs?

The available objects in Phantomjs are as follows:

  1. CookiesEnabled
  2. Cookies
  3. LibraryPath
  4. Version

6) How to delete Cookie in phantomjs?

You can use the following code to delete Cookie in Phantomjs:

if( phantom.deleteCookie('username') ) 
  console.log('Cookie deleted.');
  console.log('Cookie not deleted or does not exist.');

If the desired cookie is not present, the function will not generate any error, but it will return a false value.

To clear all cookies, simply use the clearCookies() function.


7) How to enable Cookie In Phantomjs?

You can follow the following steps to enable Cookie In Phantomjs:

  • case BrowserType.PhantomJS:
  • var service = PhantomJSDriverService.CreateDefaultService(Path.Combine(_rootPath, @"Packages\"));
  • var cookieFilePath=Path.Combine(_rootPath, @"Packages\cookie.txt");
  • if (!File.Exists(cookieFilePath))
  • File.Create(cookieFilePath);

8) Can we run test scripts in Selenium using PhantomJS?

Yes, we can run test scripts in Selenium using PhantomJS. Using PhantomJS driver with Selenium is quite easy since one can use their own implementation technique to automate test suites using PhantomJS.

Leave A Comment :

Valid name is required.

Valid name is required.

Valid email id is required.