Interview Questions

AJAX Interview Questions Android Interview Questions Angular 2 Interview Questions AngularJs Interview Questions Apache Presto Interview Questions Apache Tapestry Interview Questions Arduino Interview Questions ASP.NET MVC Interview Questions Aurelia Interview Questions AWS Interview Questions Blockchain Interview Questions Bootstrap Interview Questions C Interview Questions C Programming Coding Interview Questions C# Interview Questions C++ Interview Questions Cakephp Interview Questions Cassandra Interview Questions CherryPy Interview Questions Clojure Interview Questions Cobol Interview Questions CodeIgniter interview Questions CoffeeScript Interview Questions Cordova Interview Questions CouchDB interview questions CSS Buttons Interview Questions CSS Interview Questions D Programming Language Interview Questions Dart Programming Language Interview Questions Data structure & Algorithm Interview Questions DB2 Interview Questions DBMS Interview Questions Django Interview Questions Docker Interview Questions DOJO Interview Questions Drupal Interview Questions Electron Interview Questions Elixir Interview Questions Erlang Interview Questions ES6 Interview Questions and Answers Euphoria Interview Questions ExpressJS Interview Questions Ext Js Interview Questions F# Interview Questions Firebase Interview Questions Flask Interview Questions Flex Interview Questions Fortran Interview Questions Foundation Interview Questions Framework7 Interview Questions FuelPHP Framework Interview Questions Go Programming Language Interview Questions Google Maps Interview Questions Groovy interview Questions GWT Interview Questions Hadoop Interview Questions Haskell Interview Questions Highcharts Interview Questions HTML Interview Questions HTTP Interview Questions Ionic Interview Questions iOS Interview Questions IoT Interview Questions Java BeanUtils Interview Questions Java Collections Interview Questions Java Interview Questions Java JDBC Interview Questions Java Multithreading Interview Questions Java OOPS Interview Questions Java Programming Coding Interview Questions Java Swing Interview Questions JavaFX Interview Questions JavaScript Interview Questions JCL (Job Control Language) Interview Questions Joomla Interview Questions jQuery Interview Questions js Interview Questions JSF Interview Questions JSP Interview Questions KnockoutJS Interview Questions Koa Interview Questions Laravel Interview Questions Less Interview Questions LISP Interview Questions Magento Interview Questions MariaDB Interview Questions Material Design Lite Interview Questions Materialize CSS Framework Interview Questions MathML Interview Questions MATLAB Interview Questions Meteor Interview Questions MongoDB interview Questions Moo Tools Interview Questions MySQL Interview Questions NodeJS Interview Questions OpenStack Interview Questions Oracle DBA Interview Questions Pascal Interview Questions Perl interview questions Phalcon Framework Interview Questions PhantomJS Interview Questions PhoneGap Interview Questions Php Interview Questions PL/SQL Interview Questions PostgreSQL Interview Questions PouchDB Interview Questions Prototype Interview Questions Pure CSS Interview Questions Python Interview Questions R programming Language Interview Questions React Native Interview Questions ReactJS Interview Questions RequireJs Interview Questions RESTful Web Services Interview Questions RPA Interview Questions Ruby Interview Questions Ruby on Rails Interview Questions SAS Interview Questions SASS Interview Questions Scala Interview Questions Sencha Touch Interview Questions SEO Interview Questions Servlet Interview Questions SQL Interview Questions SQL Server Interview Questions SQLite Interview Questions Struts Interview Questions SVG Interview Questions Swift Interview Questions Symfony PHP Framework Interview Questions T-SQL(Transact-SQL) Interview Questions TurboGears Framework Interview Questions TypeScript Interview Questions UiPath Interview Questions VB Script Interview Questions VBA Interview Questions WCF Interview Questions Web icon Interview Questions Web Service Interview Questions Web2py Framework Interview Questions WebGL Interview Questions Website Development Interview Questions WordPress Interview Questions Xamarin Interview Questions XHTML Interview Questions XML Interview Questions XSL Interview Questions Yii PHP Framework Interview Questions Zend Framework Interview Questions

Top 15 PhantomJS Interview Question for 2020

1) What is PhantomJS?

PhantomJS is a lightweight headless scripted browser built on WebKit. It is used for automation web page interaction.

2) Why it is called as headless browser?

PhantomJS called as headless browser because it execution does not happen on browser which means there is no involvement of browser while executing JavaScript code, it takes over terminal.

3) What is WebKit?

WebKit is software component used for rendering web pages in web browsers (Chrome, Safari as well as other).

4) What are the objects in PhantomJS.

These are the following objects in PhantomJs:
    1. cookiesEnabled: It check whether cookie are enable or not. It return true for yes otherwise false. Its default value is true.
Syntax:
  1. phantom.cookiesEnabled
    1. cookies: It is used to get or set cookies from domain which are stored in Cookiejar. Cookie returns an object with all cookies available for the domain.
Syntax:
  1. phantom.cookies
    1. libraryPath: It store the script path which are used by injectJs function.
Syntax:
  1. phantom.libraryPath
    1. version: It is a read-only property which return version of PhantomJS instance which are running. The details are return in an object ('major': 1,'minor': 7, 'patch': 0).
Syntax:
  1. phantom.version
    1. scriptName: It is used to get current script name (this property has depreciated).
Syntax:
  1. phantom.scriptName
    1. args: It contain the script name as its first element (this property has removed).
Syntax:
  1. phantom.args

5) Name some method of PhantomJS.

Following methods are helping us to execute JavaScript without the browser:
    1. addCookie: This method is used for adding cookies in CookieJar. If successfully added it return true otherwise false.
phantom.addCookie({  

    'name' : 'Cookie name',  

    'value' : 'Cookie value',  

    'domain' : 'localhost'  

});
    1. clearCookies: This method used to delete all the cookies from Cookiejar.
  1. phantom.clearCookies();
    1. deleteCookie: It is used for deleting cookie from Cookiejar by using 'name' property
matching chookieName.  

phantom.deleteCookie('Cookie name');
    1. exit: This method exit the program when return specific return value. It there is no specific return value it return '0'.
specific return value it return '0'.  

if(condation){  

    phantom.exit(1);  

}else{  

phantom.exit(0):  

}
    1. injectJs: It injects external file from specified file into phantom. If file does not found in current directory, then libraryPath property of Phantos is used as an additional place to track the path.
var addSuccess= phantom.injectJs(filename);  

consol.log(addSuccess);  

phantom.exit();

6) What is webpage module property? Name some of them.

Webpage module property provides a facility to interact with contents inside a webpage. Some module properties are:
canGoBack

canGoForward

clipRect

Content

Cookies

customHeaders

Even

focusedFrameName

frameContent

frameName
etc.

7) What is webpage module method? Name some of them.

Webpage module keeps the method for Cookies, Frames, Page Navigation, Reload, Rendering and Uploading of Files. Some webpage module methods are:
addCookie()

clearCookies()

deleteCookie()

getPage()

goBack()

goForword()

go()

includes()

injectJs()

childFramesCount()

childFramesName()

currentFrameName()
etc.

8) What do you understand about screen capture?

PhantomJs provide facility capture screenshot of web page. This capture image can be saved in different formate such as .png, .jpeg, .pdf, .gif. It is also able to convert as PDF. Following script show the simple way for screen capture.
var page = require(‘webpage’).create();  

page.open(‘website_url’,function(status){  

page.render(‘imagename.png’);  

phantom.exit();  

});

9) How network monitoring is done in PhantomJS?

Natwork monitoring is done by using events such as onResourceRequested and DOM manipulation. This helps in monitoring the traffic for given page.

10) What is page automation?

Manipulating and loading of web pages and performing operation such as DOM manipulation by clicking buttons, etc.

11) Is PhantomJS support command line interface (CLI) execution?

Yes, PhantomJS support command line interface execution. CLI execution is done by using keyword "phantomjs" with file name. For example: "phantomjs filename.js".

12) What is the role of child process module in PhantomJS?

Child process module helps to interact with sub processes using stdin /stdout/ stderr. Child processes can be used for performing task like invoke programs, printing, or to sending mail.

13) What is REPL?

REPL is stands for Read Eval Print Loop. In PhantomJS, REPL is an interactive mode to test the JavaScript code.

14) How testing are done in PhantomJS?

PhantomJS is not a test framework. PhantomJS use different libraries known as test runner for testing. Some of the framework along with their test runner is:
Framework Test Runner
Capybara Poltergeit, Terminus
Buster.JS built-in
Mocha Chutzpah, mocha-phantoms
Jasmine Chutzpah, grunt-contrib-jasmine
Hiro built-in
WebDriver GhostDriver

15) What is file system module in PhantomJS?

File system module perform operations on files and directories. We can create, write and delete a files and directory. There are two properties in file system module:  
Separator: It is used for file paths (for windows: \, for linux: /).
Working Directory: It is a directory in which PhantomJS executes.



ADVERTISEMENT
ADVERTISEMENT