Selenium Tests: Writing nice code


Hi there,

after writing lots of selenium tests I am aware of 2 things:

  1. using wait() a lot makes total sense
  2. the code when using the facebook\webDriver classes and functions is ugly as hell

What I would like my selenium test code to look like is this:

$this->findByCSS(’#someButton’)->click()->modalOpen()->findByCSS(’#SomeOtherButton’)->click()->modalClose()->findByCSS(’#someButton .lastSent’)->selectDropdown(‘someFieldName’);

So a one-liner for a bunch of actions which belong together.
Achieving this is not too hard, and when putting everything inside these single functions in a wait(), then there is no need to ever wait manually again. Actually wait() is a very powerful function as a custom function can be passed as param.

So I will do this someday definitely. And as ATK is starting to use Selenium tests just now, why not start now with it and cooperate?

The Idea partly came from a Java project which does exactly this for Java, I forgot the name, but they have extremely short, readable test code.

Best regards


Would be nice as an extension of a context to Behat with documentation. Note that you can still use it with PHPUnit, but Mink is just so cool :slight_smile:

ATK UI now incorporates it’s own behat test-suite with selenium too, so all it takes is to create PR for ATK and add more UI tests and those can be re-used in your applications without any side-projects.