Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhantomJS, but not headless?

Is there a way to get a realtime view of what PhantomJS (or similar) is rendering?

I would like to develop my automation script while interacting with (or at least seeing a screencap of) the page it's targeted to.

like image 218
themirror Avatar asked Jul 15 '14 22:07

themirror


People also ask

Is PhantomJS a headless browser?

PhantomJS is a discontinued headless browser used for automating web page interaction. PhantomJS provides a JavaScript API enabling automated navigation, screenshots, user behavior and assertions making it a common tool used to run browser-based unit tests in a headless system like a continuous integration environment.

What is the alternative of PhantomJS?

Selenium, Electron, Protractor, wkhtmltopdf, and SlimerJS are the most popular alternatives and competitors to PhantomJS.

Why is PhantomJS deprecated?

PhantomJS is deprecated because the (sole) author decided to stop development on it. However, it's not broken, it works perfectly fine for Bokeh's needs, there is no particular reason no to use it, as long as you have a selenium version installed that supports still supports it.

Does Selenium support PhantomJS?

PhantomJS And Selenium For Web Automation (Basic) Just like any other browsers with GUI interface (Firefox, IE, Chrome, etc.), for PhantomJS also, Selenium has a standard API to support the automation.


1 Answers

No, there is no such thing. SlimerJS has the same API as PhantomJS, but runs the Gecko engine. You can see directly what is going on and run it headlessly with xvfb-run.

You will not be able to interact with it. You may want to use a screengrabber to record a video of the interaction when the tests are long and you don't want to run the test suite again if you didn't catch the problem in the test case.


The obvious way to debug PhantomJS scripts is to render many screenshots using page.render() and logging some objects to the console with

console.log(JSON.stringify(yourObj, undefined, 4));

with nice formatting.

like image 62
Artjom B. Avatar answered Oct 01 '22 11:10

Artjom B.