Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slow running acceptance test with php + codeception + phantomjs

I am moving to codeception 2.0.3 for doing some tests in various web platforms I am developing. I started doing some acceptance testing. Mainly check for pages ok and doing some form completions (sign in, sign up, nothing fancy).

I have been monitoring tests with firefox browser and we are moving now tests to a dedicated server so I switched to phantomjs as my testing browser.

Configuration in acceptance.suite.yml

WebDriver:
  url: 'localUrl'
  browser: phantomjs 
  window_size: 'maximize'
  capabilities:
      phantomjs.cli.args: ['--ignore-ssl-errors=true']

The thing is that with this headless configuration, tests are running very slowly. I mean, the test I wrote is checking that four links are OK (no error or exception message) without any fancy assertions (something which I can check in less than 20 secs) and it is taking more than a minute a half.

Am I missing something in the configuration of the testing stack? I read that phantomjs testing in this way is supossed to be fast and reliable something that can be integrated while developing but I don't seem to get it working right. I have been doing TDD in Smalltalk and maybe I am a little biased with the way that things work in that environment so maybe my expectations are too high but I had hopes that this could be a little more responsive and easy going.

I am using codeception 2.0.3 with phantomjs 1.9.7 on a linux box with php 5.5.

Any suggestion is welcomed. Thanks!!!

like image 928
DraQ Avatar asked Sep 11 '26 03:09

DraQ


2 Answers

I had very slow running tests and started using strict locators. That sped up things a lot.

Instead of writing:

$I->fillField('username, 'john');

which will try and fail many locator types before actually working, specify the locator you are using and write:

$I->fillField(['id' => 'username'], 'john');

or

$I->fillField(['class' => 'username'], 'john');

or

$I->fillField(['css' => 'input .username'], 'john');

Read here: http://codeception.com/docs/04-AcceptanceTests#Click

like image 108
Martin Ezequiel Avatar answered Sep 15 '26 14:09

Martin Ezequiel


Could be problem with phantomjs, usually headless with Codeception PhpBrowser goes very fast, try to switch to it.

For in-browser try to use Codeception WebDriver + latest selenium 2 standalone.

Also if you are developing with some framework, you can check if it is present in Codeception modules list. If so you can use it, it runs much faster than PhpBrowser since it does not need any server and works with symfony dom - crawler and browser - kit.