Sunday, January 31, 2016

Blackboard Design Pattern - Layout Automation


    This software pattern is one of the few that still require serious Googling to be found. If it wasn't for a research PoC project I also would pass by it. But after a couple of days working with this concept I have to say, that I haven't been so interested in an idea for a long time ago. You will see it being classified as  behavioral or even architectural design pattern - depending from the usage. Most of the times its use case is in the fields of AI computing. Yes - it is such powerful concept. Even if my demo is just scratching the surface I also used such frameworks. In my case - image recognition. I already knew such library called AForge.Imaging, so putting it all together wasn't that hard.

   My vision that I had to prove was Stable web site automation based only on the layout. If you ever had your hand on web site testing you know the constant shifting sands of this domain. So the questions is - how to provide reliable UI tests? It is obvious that most DOM based solutions are highly dependant to the changes, no matter how good you are with XPath or CSS locators. But if we use the web element's layout we could decouple our tests from the HTML. Instead of keeping text based selectors, now we work only with images. And they don't change every day, once you have the designer's mockups you are done with the maintenance. This idea is not new and tools like Sikuli are gaining ground as we speak. But they do have certain disadvantages stopping them from dominating the domain. First one is that they require personal desktop - you can't run in parallel. My approach solves this with Selenium's TakeScreenshot  interface.  So you can keep the speed of the tests and only throw iron (computing power) when you need to scale it.

    Let's get back to the Blackboard pattern. Its main advantage is that works naturally with the development mindset. This pattern solves problems when there are no deterministic solutions known. We do this on a daily basis. It helps us coordinate separate, disparate systems that need to work together, or in sequence, continually prioritizing the actions it takes. It also allows our code to work in multiple threads to work closer together on separate processes, polling and reacting if needed.

    Example code implementation...

No comments:

Post a Comment