Facade layer? pffff what?!?! why?!?!?

Hey Y’all,

Today I want to talk about the importance of creating a facade layer to your selenium framework…

But, wait, What exactly is a facade layer?

Well, Facade layer is actually part of a design pattern called “Facade Pattern” I will try to sum it up for you here in points in this post today, but if you want to read about “Facade Pattern” click here: Facade Pattern

 

OK, got it, but how does it relate with my work with Selenium?!?!?

A facade is an object that provides a simplified interface to a larger body of code, in our case a facade will wrap webdriver, so our entire framework will speak with his facade and never directly with Selenium.

 

Now I understand what is a facade layer and how to implement it, but why should I? what is my motivation?

This question will be first addressed with a short story…

Back in the day I worked in a nice place, we used selenium version 1 and we had about 2,000 tests for our system, When webdriver (or Selenium v2) was released we were excited actually, but we couldn’t re-write all of the 2,000 tests, but because of some enthusiastic young developer we had a facade layer to selenium v1, so actually we only needed to change our code in one class and all tests were affected immediately (of course it wasn’t automatically “Green”, but it saved us 95% of the work with this migration).

 

So now, after telling this nice story, why more? I’m not convinced!

Boy, you are a though crowed! 🙂

I’ll some up the motivation here:

  1. You have one interface to speak with if selenium API changes you need to change I one place and one place alone.
  2. You discovered a new UI automation that works better than Selenium for you, no problem! just need to change the implementation in the facade (and not to break the facade Interface).
  3. You define how to simplify several methods, actually, you are responsible for how the API looks – not selenium (or other product if you decide to change).
  4. You can intervene in the Selenium methods, I implemented for example for each time a click is invoked to an element it will wait for the element to be presented, that allowed the QAs and developers to not think of waiting problems.
  5. You can magnify the Selenium methods with the same interface you currently have, I added a map that tells me in what frame I’m in now, and what are the frames that I came from 🙂

Actually, there are tons of reasons, convinced yet?

If so, read about the ultimate facade layer for your selenium tests: The Page Object design pattern conundrum.

 

 

Keep automating,

Raz Shuty.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s