Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use Selenium WebDriver to drive PhantomJS?

I’m going through the documentation for the Selenium WebDriver, and it can drive Chrome for example. I was thinking, wouldn't it be far more efficient to ‘drive’ PhantomJS?

Is there a way to use Selenium with PhantomJS?

My intended use would be web scraping: The sites I scrape are loaded with AJAX and lots of lovely JavaScript, and I’m thinking this setup could be a good replacement for the Scrapy Python framework that I’m currently working with.

like image 847
Joseph Avatar asked Jun 27 '12 12:06

Joseph


People also ask

Does Selenium support PhantomJS?

Selenium considers PhantomJS as deprecated, so you need to us either Chrome or Firefox in headless mode.

What is WebDriver PhantomJS?

PhantomJS is a headless Webkit, which has a number of uses. In this example, we'll be using it, in conjunction with Selenium WebDriver, for conducting basic system tests directly from the command line. Since PhantomJS eliminates the need for a graphical browser, tests run much faster.

Is PhantomJS faster than Selenium?

Key Differences Between Selenium and PhantomJS Being a headless browser, the interactions are much faster than the real browser. So the performance time is smoother in PhantomJS than in Selenium.


1 Answers

PhantomJS now includes the GhostDriver project.

You are also suggested to use PhantomJS directly or with a convenience library such as CasperJS. CasperJS is specifically designed to make it easy to do sequential operations to web pages, perfect for many automation tasks.

Disclaimer: I am the author of PhantomJS.

Edit: As noted in Nick's answer, GhostDriver is now included in PhantomJS.

like image 144
Ariya Hidayat Avatar answered Sep 18 '22 17:09

Ariya Hidayat