Bruno Bruzzano
Bruno Bruzzano

Reputation: 477

PhantomJS slower than ChromeDriver, using Selenium

I'm trying to use PhantomJS 2.0/GhostDriver instead the ChromeDriver, since I have read I could speed up my UI tests. This is the test code I'm running, as part of a Junit test:

@Override
public void runTestCase() throws Exception {
    long startTime = System.currentTimeMillis();
    // log in as admin
    Login.loginAs("admin", "password");
    System.out.println(System.currentTimeMillis() - startTime);
}

The loginAs function fills in the text fields for the username and password, then click on the submit button and finally moves in the home section of the new returned page.

Now, I'm running once a time this simple test using both Phantomjs and ChromeDriver as driver for Selenium in Java (v2.45). They are initialized as follow:

I'm running my test on a 64bit Windows 7 machine. So, having a look the time took by the test, I always note that ChromeDriver is faster than PhantomJS. Always. For instance, if the test with ChromeDriver takes about 3-4 seconds, the same with PhantomJS takes about 5-6 seconds.

Has anyone experienced with this issue? Or could anyone give me any reason for that? Am I setting something wrong?

Furthermore, if you need more details, let me know.

Upvotes: 3

Views: 7363

Answers (3)

Michal
Michal

Reputation: 3276

"PhantomJS is a headless WebKit scriptable with a JavaScript API" as it's explained on the main page of the project. Google split from WebKit to create Blink to use it in Chrome. What are the main differences between them - unfortunately I'm not the expert here.

I run one of my really long scenarios both on Chrome and PhantomJS and to my surprise the difference was pretty significant:

  • PhantomJS - 583.251 s
  • Chrome - 448.384 s

Using PhantomJS doesn't bring performance benefits in my case but running tests headless does. I can use machine without graphical desktop and save computing power for some additional threads.

Upvotes: 1

Dan F
Dan F

Reputation: 41

I have found that this setting uses a lot of memory that seems to keep growing:

cliArgsCap.add("--load-images=false");

But when I use this setting the memory usage is stable:

cliArgsCap.add("--load-images=true");

Upvotes: 4

Robbie Wareham
Robbie Wareham

Reputation: 3438

The slowest aspect of a web page is the downloading of html, JavaScript, css, images, etc and making AJAX request.

To anybody who says Headless is faster, how can headless address any of these?

Upvotes: 0

Related Questions