PhantomJS is a scripted, headless browser used for automating web page interaction. One major use case of PhantomJS is headless testing of web applications. It is suitable for general command-line based testing, within a precommit hook, and as part of a continuous integration system.
Execution using Phantom JS as Default Browser
If you wish to execute an artifact using PhantomJS then you need to set Browser name as PhantomJS while using Open Browser keyword or make it as the default browser.
Suppose you want to execute a Test Case using PhantomJS then you can follow the process mentioned below:
Enter the Browser as PhantomJS as the data input arguments of OpenBrowser keyword.
An alternative approach
Leave the Browser data input arguments of OpenBrowser keyword blank. While running the Test Case, go to the Local Execution Wizard window.
Check the Show Advanced Settings checkbox and Click Next.
Set required settings and click Next.
You can enter Session Tags from here. Click Next.
Set the Default Browser Value as PhantomJS and click Finish.
The execution will begin without opening any separate specific window for the browser and the logs will be generated in the agent as shown below:
This is how execution takes place using PhantomJS.
Advantages and Limitations
Phantom JS- Advantages:
- It results in better performance.
- It requires less memory for execution as compared to any other browser since it is headless and does not have any specific UI.
Phantom JS- Limitations:
- All the applications can not be executed using PhantomJS.