1

I am using phatnom js driver for my selenium test cases to overcome the headache of chrome driver.I see it is taking lot of time to execute the test cases.I tried html diver prior to phantom.Since html driver has issues in finding elements I focused on phantom js.

The concern with phantom js driver is it takes lot of time to execute test cases.I set the logging to none to avoid unnecessary loggin in phantom Are there any ways we can avoid this time execution for test cases?.

Phantim js version :2.1.1
Selenium :2.52.0

Any help would be appreciated.

1

2 Answers 2

2

PhantomJS was abandoned, author recommends to switch to headless Chrome.

Parallelization proposed by dzieciou might help, but you will be spending time to improve wrong tool.

3
  • I agree using headless Chrome might be a better solution than PhantomJS for different reasons (including testing with a real browser). But is speed one of those reasons? Do you have some benchmarks showing that? For instance, one of ways to speed up PhantomJS was to prevent it from loading images: stackoverflow.com/questions/29430515/…
    – dzieciou
    Commented Jul 6, 2017 at 5:03
  • Thanks Peter I would like to follow with dzieciou.Here my question is related to speed related to execution of test cases .Yes I do agree that maybe headless chrome would be good option but not sure at this point I can follow that since we have achieved everything in Phantom.I will consider your inputs.
    – Pradeep
    Commented Jul 6, 2017 at 7:40
  • 1
    @dzieciou - Headless browser is supposed to be a bit faster, because it does not spend time (CPU cycles) redrawing the screen. I agree with you that such speed increase is only marginal, and running tests in parallel is right way to go. But running headless Chrome in parallel, not PhantomJS. Commented Jul 6, 2017 at 13:39
2

There are multiple solutions:

  • Use faster locators like id and name. See What makes a good selenium locator?
  • Run your tests in parallel
  • Change part of your tests to REST API tests, component and unit tests
  • If you're using your tests as gateway control, e.g., to decide whether to deploy a build to next environment or production, separate your tests. Use short and stable tests for gateway control, and longer tests for discovering bugs once in a while (see Winning with Flaky Test Automation for details of this technique).

There more suggestions here: How To Make Selenium WebDriver Scripts Faster.

Note also that PhantomJS does not match any real browser, so if you care about credible tests you better go for a real browser. There's currently headless Chrome, but I don't know whether it is faster than PhantomJS or normal Chrome.

2
  • Hi dzieciou, We are following first two steps i.e
    – Pradeep
    Commented Jul 6, 2017 at 7:42
  • @Pradeep Good to know!
    – dzieciou
    Commented Jul 6, 2017 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.