2010. június 11., péntek


Ok i give up. I will move to a more coder friendly blog engine.

New URL for my Blog is: http://alternateillusion.com/

I'm a co writer there.

Bye Bye BlogSpot.

Xml Serialization with - java - SimpleXml

For those of you out there who have problem implementing some complex xmls i have a good example for you:

Xml :
Elements DivContainer name="asdf" Div name="Carthago1" test Teszt1 test Div Div name="Carthago2" test Teszt2 test Div DivContainer DivContainer name="asdf2" Div name="Carthago2" test Teszt2 test Div Div name="Carthago2" test Teszt3 test

And this is your Class Hierarchy representing it:

public class UIElement
public List divContainers;

public class DivContainer
@ElementList(name="DivContainer", inline=true)
public List

public String name;

public class Div
public String test;

@Attribute(name="name", required=false)
public String name;

And the serialize code:

public void testXml()
Serializer serializer = new Persister();
File source = new File("c:\\tmp\\test.xml");
UIElement ui = null;

ui = serializer.read(UIElement.class, source);
} catch (Exception e)

for (DivContainer divc : ui.divContainers)
for (Div div : divc.divs)
System.out.println("Value of test: " + div.test);

You have to look out for two things... First note the @Root under Div tag. That is necessary there. Writing in the attribute name there is necessary too. Also the 'inline' tag. Without them it wont work.

Again sorry for the indentation problem... Blogspot is lame in detecting code.


2010. június 10., csütörtök

Oil crysis

One question only...

Why use something that cannot be replenished and you know that you will ran out of it eventually...

So why? Sure... because it was cheap and burned good... Well fuck you history for screwing up our generation.


I'm reading a bunch of blogs in a day. I'm reading actually quite a few or at least i follow them on daily basis.

After a while i noticed two things.

First: They begin to mimic each other. They are mostly blogs about testing, but they also are trying hard to write about every day knowledge like psychology and human behavior.

Second: They are trying hard to be productive. To update lots of times to always write something new. But... I'm following these people for quit some time now. And i'm reading lots of magazine. I'm reading review and stuff like that. And to be honest i see LOTS of repetition. I see LOTS of redundancy.

They talk about the same thing over and over again, by using other concepts and other wordings. But when you are good enough in your territory and you begin to see things and know stuff you begin to realize that all the posts that you are reading are somehow either connected or that you already read about it somewhere.

There are quite a few posts about basic knowledge for testers. Quite a few posts about human behavior. Posts about heuristics post about psychology. Post about life style about testing environments. Posts about conferences posts about knowledge,what to know, what to do, how to handle situations, what to do when you are in a certain position, how testing evolves, how people evolve, how managers see us, how community sees us...

Although i Do thing these posts are really good and i learned LOTS of things from these people, i do think that they are beginning to repeat them self to much.

As an automation tester i always find something new for myself. Selenium migrating with webdriver, javascript evolving, java evolving, technology moving on..

But testing? People will always be people. Testing came a HUGE way along the road in the past 6 years of me being a tester. But if nothing remarkable new happens with people or with workplaces then i do think that people will always be people. And testers will always be testers.

Don't get me wrong.. I DO think that EVERY tester should follow these people and read there teachings because that made me what i am today.

So go on... Follow: James Bach, Jon Bach, Cam Kaner, Michale Heusser, Ajay Balamurugadas, Brian Heys, David Alfaro, Ben Simo ( Quality Frog ), Jeff Fry, Cedric Otaku, Coding QA podcasts, Adam Goucher ( Who apparently wrote a similar post to mine... I rest my case :D ), http://www.testingreflections.com/, Gojko Adzic, TestSideStory (http://testsidestory.wordpress.com/), UnimaginedTesting (http://www.unimaginedtesting.ca/blog/) Guarang Shah, Marlena Compton and lots of other people. ( Sorry if i have left somebody out. )

Take care,

Selenium Framework Structure - Java - Continued

So... Last time we had everything wired up in the framework.

Just watch out to comment enough in your xml file or you will get confused what is what no matter how meaning full names you give your elements.

So you want your tests to run every night and you want your developers to run these tests before they commit.

For the first part it's easy. For the second you need to do some extra work.

You see programmers are lazy people. They don't want to bother to set anything not even editing a config file. So you need to make sure that they can run something with two clicks MAX. Or one command line argument.

So what you need to do is using testng you need to organize your tests into groups. Groups like:

  • Smoke Test

  • Slow Smoke Test

  • Home Page test

  • Login Test

  • User Dashboard settings test

And so on and so fort. You can achieve this by using the java annotation @ at class level.

So like:

@Test(groups = { "DashboardTests" })

After defining groups you can use testng-s xml setting file to create a config that runs only these tests like :

test name="Regression1"



include name="DashboardTests"




This way you are running the group of tests. So every test that is in that particular Class. You then would save this xml into an xml named : AllDashboardTests.xml and the developer needs only to run that one.

Last but not least you need to set your ANT files.

For that i recommend using separated projects under eclipse. Why? Because you have more then one iteration of a web site. You have versions that needs to be automated not just one.

So i recommend using more projects Like:

  • Main automation project: Would contain utility classes, libraries, stuff that is constant over all of your projects

  • Version One: Would contain files specific for this version. UI Elements, Implemented test cases, steps, configuration files.

  • Version Two: Would contain files specific for this version.

So for this structure you need an ant script that can work with all these projects. For that you would have a main script under your Main Automation Project project and several smaller scripts under each version that contains useful information or only linkage to the main script.

The main script would handle everything that is constant over all your projects that means:

  • Building the files

  • Executing tasks like: check style, copying, creating directories

  • Creating report

So your smaller ant script would only contain information like, which testng xml to execute.

I also recommend creating an ant target that starts and stops selenium. So your would only have run something like this:

ant test-start-selenium

This would then run the tests and start selenium too. And stop it too of course. This would look like this:


depends="selenium-start, runtests, selenium-stop"/>


target name="selenium-start"

java jar="${automationframework.dir}/lib/selenium-server-standalone-2.0a4.jar"



arg line="-firefoxProfileTemplate ${firefoxProfileTemplate}"


sleep seconds="1"/



target name="selenium-stop"

get taskname="selenium-shutdown"




So this would start your server ( and add a parameter to it called -firefoxProfileTemplate ). This way all you have to do is execute one little task and it would do everything for you.

Easy eh?

For Hudson and Selenium Grid integration please see this:


I didn't began to write down how to do it, because this tutorial is great for it.

And i didn't quite yet did it myself. :) So i have to do that one too.

I hope you liked my post, if something is left out, please tell me.


Sorry for the bad edit... I gave up with blogger handling xml tags... Damn them.

2010. június 4., péntek

Selenium Framework Structure - Java

Hi Guys!

Today i want to talk about a topic that is not often talked about. This is the structure of the framework you are building for automated testing and how you could build a framework that is easily maintained and can be expanded any time.

These are general suggestions your implementation may wary based on your environment.

And they will be made using java.

So here goes nothing...

Chapter 1. Technology

What kind of technology do you should use when you want continues integration, nightly builds, any easily executed tests.

First of all... Let go over the basics:

1.1. Continues integration

This means that you always have some functions implemented that you always build integrate and test and that mostly all of these are happening automatically. This means that there is a server or some kind of software that runs builds over night or at weekends if the build is to big.

Example softwares that are free of use are: Hudson, Cruise Control, Apache Maven, Cascade, Buildbot, and so on and so fort. The mainly used are Cruise Control, Hudson, Maven and maybe rationals tool.

These can be configured to build your application every night. These tools work with lots of configuration and lot of ant/nant scripts.

1.2. Automatic Building

So you set up your environment and you have your Maven / Hudson / whatever set and ready to go... What you need now is a building tool. For this there are two great building tools that are used all over the world. These are Ant and Nant. Where nant is a .NET version of ant really.

Ant can be used to build everything really. And it has a lot of other functions too, like. Creating directory, moving files, executing tasks, integrating behavior and lots more.

These you will use to create build.xml-s that build your automation framework and executes the tests you got.

1.3. Test run framework

Next you need a framework that will organize and run your tests. These usually are xUnit where x can be a lot of things like j for java and n for .NET and r for Ruby and p for PHP and so on. And then for java there is testng what i'm currently using. It is a great tool but you have to decide for yourself which one you will use.

1.4. Web Automation Framework

There are a LOT of good automation frameworks out there. And i mean a LOT.

I will just name a few of the big ones.

  • Selenium
  • WebDriver
  • Watir
  • Watin
  • Ranorex
  • Sahi
  • WebAction
So there... These are a LOT of tools. I'm using Selenium currently because i believe that they will rule over all in time. :) For a huge list look at this: http://www.softwareqatest.com/qatweb1.html

Chapter 2. Main structure

So let us talk about how your environment should look like in java...

2.1. Modularity and basic principles

For your environment to work properly you have to consider a few things first...

First, that it will expand beyond any comprehension. This means that whatever you think how big it will get, IT WILL GET BIGGER! You will have over thousands of files that will contain over thousands of code and other stuff.

You will have to write a structure that can handle this kind of load. And you have to write it so that can handle maintenance. That means that if something breaks than you wont lose your head trying to find the problem. And then fixing the problem introduces another couple of problems.

That is something we don't want.

And it can be easily avoided for that matter. You don't need so much fancy Design Patterning or to complicated stuff. There are only a few rules that you have to follow.

Everybody for himself.

Means that everything you write every object every file only needs to be aware of himself. It only needs to take care of stuff regarding to that object only.

For example you have a class that creates ui elements that you work with. That means that everything regarding ui objects is handled in that class. It means that if some kind of problem occurs with an element, like the element is not found, then you know that you have to look in that class and that class only. ( And in the tests because sometimes you just forgot something or misspelled it :P )

KISS - Keep it Simple Stupid.

This is a basic concept and it works. You don't need to fancy tests and scripts that a programmer would create. These are programs of course but they need to be kept as simple as possible. Why? Because not all of your testers have a degree in programing science or even care to have one.

You need to keep it simple for maintainability too because the simpler the easier to edit and poke in it.

Everything in one place.

This is similar to everybody for himself. It means that everything you write or edit needs to be in one place only. This means ui elements, configurations, variables, names, users, passwords, settings, instantiations and so on and so fort.

For example you have selenium and you can start it in more then one way. Than you should have a class dealing with JUST selenium. Or you have a couple of settings like usernames you are using to test with. These should be kept in Java property files.

Chapter 3. Hard facts

So let go forth and present you with an example. Just so you see all these things working together.

For example let's say you have to automate a web page.

Technologies you are using are:

  • Selenium
  • TestNg
  • SimpleXml for Java
  • ReportNG - Reporting for TestNG - Nice piecharts
  • Ant
  • Hudson
Okey. What you want to achieve. You want your tests to run every night and you want your developers to run these tests before they commit. At least a portion of them not all. Just for example the login screen.

First you build your framework.

You have selenium in a separate class taking care of.

You have Base classes for All your tests taking care of functions that all tests should run, like setUp and tearDown.

Your tests should look something like this: doLogin; checkStatus; doLogout;

This is easily achieved too. You just need to hide your logic from your tests. Have test classes and then have Implementation classes. The test would only look like this:

public void loginTest()
LoginPageImplementation loginPageImpl = new LoginPageImplementation(seleniumInstance);


Tada.... You have your test. It is easily readable. You know what it does although your don't have a clue what the implementation looks like. The implementation would be something like this:

public void doLogin()

Tada.. Of course there are a bunch of more stuff to it like waiting for a page, and checking if the login was a success but again. It is really simple and you know what it does.. Why?

Here is a trick hidden again. What does username.xpath mean? Well selenium works with locators. These locators find elements on the web page.

Again like i said every man for himself. You need to encapsulate the ui objects on a webpage. How you do that is completely up to you.

I'm using xml Serialization. That is why i'm using SimpleXML for java. I have a class that holds UI objects and an XML telling how does objects are working.

For example:

The xml would look something like this:

And your object hierarchy would look like UIElement - Elements. And in Elements you would have WebElement value... ( Look under the documentation for SimpleXML it is really simple! )

This way if something on the page changes you again have to look only at ONE PLACE!!

This is really important in ways of maintainability because if something fails and you have to look at at last 5 places to find a bug... well that is a sign you are doing something wrong.

Chapter 4. Last words

So i hope that helped... Any constructive comments are appreciated and tell me if something was too complicated or left out...

Stay Tuned for the next Post on which i explain how to put it together with ANT TestNG and Hudson! :)


2010. június 3., csütörtök

GTD - Getting things done

Hi folks!

Today i want to write about GTD. It is another buzz word that got reinvented and sold to stupid people.

Guess what, I've been doing GTD for at least 10-15 years. We just called it frigging note taking back then. You took your little notebook and a pencil and you started writing down stuff. And if you wanted to scribble something next to an objective then you did it in under half a minute.

GTD didn't require a fancy UI. Fancy UI is just distracting. It takes your heart of the task ahead. And despite any kind of alert you never will use a software for GTD. Because they are cumbersome. They don't work fast enough, they aren't around, you close them or put them on tray and never ever care about them again. And they are slow. Sure you can add a new task in under a minute but you wont. Because you play around with the time and deadline and stuff like that.

You don't have to and it's only distracting you. And if you want to doodle a picture next to a task? Sure you can attach nice picture. Nice pictures are good. BUT THEY ARE NOT HELPING! Why? Because they distract you. You begin to look for the task only to see the nice picture but you aren't actually working on the task.

Imagine i write down a task and draw a little dog next to it. With a pencil? 25 seconds. With the machine? More... You search for the picture, that doesn't quit do it, this one isn't black, on this the dog looks stupid, the task has a false dead line, maybe i add some more... The list looks not organized... etcetcetc...

So I've been doing this for years and now some guy comes around and tells me i gotta give him credit because i'm doing what he said?! Hell no!

Programs will never be able to give you the satisfaction a good pencil and a good moleskine notebook will give you. I'm coming in every day and the first thing i do i writing down my tasks ahead of me for that day. Every day a new page even if i have some tasks left on the other day. then i'm writing then down again. Because you have to remind your brain every day. And then i leave my notebook opened on that day in from of me or next to my laptop. It's always around i can always see my handwriting and the fine paper of the notebook wanting me to write on it. Wanting that i have to complete some tasks and fine some new ones i can scribble down.

So people... Get to it. Get some paper and a good pencil and you will see production increase. And forget GTD it's only a damn word. Do what you like and how you like it. NOBODY can tell you what you want and how you want to do it.

2010. június 2., szerda

Usefull stuff

If you have multiple working environments and machines and you have files that you gather and put it on an ftp server or a usb stick or things like that... Then here is a solution for you:

If you know dropbox then still here is a small tip for you...

You can synchronize your work environment not inly by sharing files... You can share settings too!!!

So if you for example make your eclipse save your profile into a dropbox folder, then when you get home and turn on your home computer, your eclipse will open up where you left it at your work.

Or firefox profile settings into a dropbox and when you get home and open your firefox it will open the same pages that you left open at work.

This is a very effective and very cool way to use dropbox.

Just don't forget to close all the porn pages you left open at home ;))