Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace Chrome with PhantomJS for use with Selenium and Conductor?

I am successfully using the Conductor framework to scrape data off a website. I use the Chrome browser and therefore I have installed chromedriver.exe in the root of my project.

To speed things up I want to replace Chrome with the headless PhantomJS browser. I installed PhantomJS as explained in the answer to this Stackoverflow question: PhantomJS & Conductor Framework and have changed the browser to Browser.PHANTOMJS in @Config.

Whatever I do however, I get no results.

I found no documentation how to setup PhantomJS for use with Selenium or PhantomJS.

The question How to Implement Selenium WebDriver with PhantomJS and Can we Use Sikuli with PhantomJS? did not help either.

How to replace Chrome with PhantomJS for use with Selenium and Conductor?

like image 422
nilo de roock Avatar asked Oct 05 '16 09:10

nilo de roock


People also ask

How do I run Chrome headless?

As we have already seen, you just have to add the flag –headless when you launch the browser to be in headless mode. With CLI (Command Line Interface), just write: chrome \<br> --headless \ # Runs Chrome in headless mode.

What does headless chrome mean?

A headless browser is a web browser without a graphical user interface. Headless browsers provide automated control of a web page in an environment similar to popular web browsers, but they are executed via a command-line interface or using network communication.

What is ChromeDriver?

WebDriver is an open source tool for automated testing of webapps across many browsers. It provides capabilities for navigating to web pages, user input, JavaScript execution, and more. ChromeDriver is a standalone server that implements the W3C WebDriver standard.


1 Answers

The trouble you are having appears to be due to an older version of the PhantomJS library included in Conductor. The error when running PhantomJS can be found in this imported issue on the Selenium Github. The remedy is to import a fork of PhantomJS which works with the newer releases of Selenium.

You can easily implement this by editing the pom.xml file and swapping

<groupId>com.github.detro</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>${phantomjs_version}</version>

with

<groupId>com.codeborne</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.2.1</version>
like image 51
Harry King Avatar answered Oct 20 '22 10:10

Harry King