Selenium Tests: Writing nice code


#1

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